Skip to contentSkip to conversation

btrfs: prevent memory leak in super.c

PATCH NAK Navid Emamdoost 2 participants 2 messages Sep 23, 2019 – Sep 24, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: prevent memory leak in super.c

In btrfs_mount_root the last error checking was not going to the error handling path. Fixed it.

---
 fs/btrfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/super.c +1 -1
index 1b151af25772..9f3f62c000fa 100644
@@ -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);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Navid Emamdoost

In btrfs_mount_root the last error checking was not going to the error handling path. Fixed it.

NAK

deactivate_locked_super actually calls btrfs_kill_super which in turn calls generic_shutdown_super which does the required shutdown sequence.

Quoted 18 lines
---
 fs/btrfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/super.c +1 -1
index 1b151af25772..9f3f62c000fa 100644
@@ -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);