[PATCH] btrfs: prevent memory leak

2019-09-23 Thread Navid Emamdoost
In btrfsic_mount if btrfsic_dev_state_alloc fails the allocated state
will be leaked. It needs to be released on error handling path.

Signed-off-by: Navid Emamdoost 
---
 fs/btrfs/check-integrity.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 0b52ab4cb964..8a77b0cb2db3 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -2941,6 +2941,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
if (NULL == ds) {
pr_info("btrfs check-integrity: kmalloc() failed!\n");
mutex_unlock(&btrfsic_mutex);
+   kvfree(state);
return -ENOMEM;
}
ds->bdev = device->bdev;
-- 
2.17.1



[PATCH] btrfs: prevent memory leak in super.c

2019-09-23 Thread Navid Emamdoost
In btrfs_mount_root the last error checking was not going to the error
handling path. Fixed it.

Signed-off-by: Navid Emamdoost 
---
 fs/btrfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1b151af25772..9f3f62c000fa 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1565,7 +1565,7 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
security_free_mnt_opts(&new_sec_opts);
if (error) {
deactivate_locked_super(s);
-   return ERR_PTR(error);
+   goto error_close_devices;
}
 
return dget(s->s_root);
-- 
2.17.1