btrfs: Fix an error pointer vs NULL check
diff mbox series

Message ID 20200805095147.GB483832@mwanda
State New
Headers show
Series
  • btrfs: Fix an error pointer vs NULL check
Related show

Commit Message

Dan Carpenter Aug. 5, 2020, 9:51 a.m. UTC
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 <dan.carpenter@oracle.com>
---
 fs/btrfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov Aug. 5, 2020, 10:34 a.m. UTC | #1
On 5.08.20 г. 12:51 ч., Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  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 53639de3a064..e529ddb35b87 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -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);
>
David Sterba Aug. 10, 2020, 3:06 p.m. UTC | #2
On Wed, Aug 05, 2020 at 12:51:47PM +0300, Dan Carpenter wrote:
> 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.

Patch
diff mbox series

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 53639de3a064..e529ddb35b87 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -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);