summaryrefslogtreecommitdiff
path: root/libdiskfs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-01-01 11:32:32 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-01-01 11:32:42 +0100
commita9c74187eff3dcd7aa23a735e8ef07abf1546514 (patch)
tree5b0ca96dbe84b433d2e42246f070fe5eb59186e6 /libdiskfs
parentb6a238ea84aa8c7e07b906669cd279f901e7d137 (diff)
make_peropen: Fix memory leaks on error
Diffstat (limited to 'libdiskfs')
-rw-r--r--libdiskfs/peropen-make.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
index 827aa2d8..b4564a97 100644
--- a/libdiskfs/peropen-make.c
+++ b/libdiskfs/peropen-make.c
@@ -34,7 +34,10 @@ diskfs_make_peropen (struct node *np, int flags, struct peropen *context,
err = fshelp_rlock_po_init (&po->lock_status);
if (err)
- return err;
+ {
+ free (po);
+ return err;
+ }
po->filepointer = 0;
refcount_init (&po->refcnt, 1);
@@ -48,7 +51,11 @@ diskfs_make_peropen (struct node *np, int flags, struct peropen *context,
{
po->path = strdup (context->path);
if (! po->path)
- return ENOMEM;
+ {
+ fshelp_rlock_po_fini (&po->lock_status);
+ free (po);
+ return ENOMEM;
+ }
}
po->root_parent = context->root_parent;