btrfs: Fix an error pointer vs NULL check
Subsystems (2)
PATCH 1/1 btrfs: Fix an error pointer vs NULL check
The btrfs_get_subvol_name_from_objectid() function never returns NULL, it returns error pointers. Update the check accordinglingly to prevent an Oops.
Fixes ca346708eb17 ("btrfs: don't show full path of bind mounts in subvol=")
Signed-off-by Dan Carpenter <[email protected]>
--- fs/btrfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/super.c +1 -1
@@ -1475,7 +1475,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) BTRFS_I(d_inode(dentry))->root->root_key.objectid); subvol_name =btrfs_get_subvol_name_from_objectid (info,BTRFS_I (d_inode (dentry))->root->root_key.objectid); -if (subvol_name) { +if (!IS_ERR (subvol_name)) {seq_puts (seq,",subvol=" );seq_escape (seq, subvol_name," \t\n\\" );kfree (subvol_name);
Signature · 1 line
2.27.0
Quoted 6 lines · Dan Carpenter
The
btrfs_get_subvol_name_from_objectid()function never returns NULL, it returns error pointers. Update the check accordinglingly to prevent an Oops.Fixes ca346708eb17 ("btrfs: don't show full path of bind mounts in subvol=")Signed-off-by Dan Carpenter <[email protected]>
Reviewed-by Nikolay Borisov <[email protected]>
Quoted 18 lines
--- fs/btrfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/super.c +1
-1@@ -1475,7 +1475,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) BTRFS_I(d_inode(dentry))->root->root_key.objectid); subvol_name =btrfs_get_subvol_name_from_objectid (info,BTRFS_I (d_inode (dentry))->root->root_key.objectid); -if (subvol_name) { +if (!IS_ERR (subvol_name)) {seq_puts (seq,",subvol=" );seq_escape (seq, subvol_name," \t\n\\" );kfree (subvol_name);
Quoted 5 lines · Dan Carpenter
The
btrfs_get_subvol_name_from_objectid()function never returns NULL, it returns error pointers. Update the check accordinglingly to prevent an Oops.Fixes ca346708eb17 ("btrfs: don't show full path of bind mounts in subvol=")
Thanks for catching it, the patch is in a development branch and the commit id is unstable so I'll fold the fixup.