btrfs: Fix error code in btrfs_sysfs_add_mounted()
diff mbox series

Message ID 20200110055126.4rhhfsotll6puma7@kili.mountain
State New
Headers show
Series
  • btrfs: Fix error code in btrfs_sysfs_add_mounted()
Related show

Commit Message

Dan Carpenter Jan. 10, 2020, 5:51 a.m. UTC
The error code wasn't set on this error path.

Fixes: e12ebce8a4a8 ("btrfs: sysfs: make UUID/debug have its own kobject")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/btrfs/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Anand Jain Jan. 10, 2020, 9:13 a.m. UTC | #1
On 10/1/20 1:51 PM, Dan Carpenter wrote:
> The error code wasn't set on this error path.
 >
> Fixes: e12ebce8a4a8 ("btrfs: sysfs: make UUID/debug have its own kobject")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   fs/btrfs/sysfs.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index 58486229be95..55e4ed1af29c 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -1288,8 +1288,10 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
>   
>   #ifdef CONFIG_BTRFS_DEBUG
>   	fs_info->debug_kobj = kobject_create_and_add("debug", fsid_kobj);
> -	if (!fs_info->debug_kobj)
> +	if (!fs_info->debug_kobj) {
> +		error = -ENOMEM;


  uh-oh right.

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand

>   		goto failure;
> +	}
>   
>   	error = sysfs_create_files(fs_info->debug_kobj, btrfs_debug_mount_attrs);
>   	if (error)
>
David Sterba Jan. 10, 2020, 5:06 p.m. UTC | #2
On Fri, Jan 10, 2020 at 08:51:27AM +0300, Dan Carpenter wrote:
> The error code wasn't set on this error path.
> 
> Fixes: e12ebce8a4a8 ("btrfs: sysfs: make UUID/debug have its own kobject")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, folded to the original patch.

Patch
diff mbox series

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 58486229be95..55e4ed1af29c 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -1288,8 +1288,10 @@  int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
 
 #ifdef CONFIG_BTRFS_DEBUG
 	fs_info->debug_kobj = kobject_create_and_add("debug", fsid_kobj);
-	if (!fs_info->debug_kobj)
+	if (!fs_info->debug_kobj) {
+		error = -ENOMEM;
 		goto failure;
+	}
 
 	error = sysfs_create_files(fs_info->debug_kobj, btrfs_debug_mount_attrs);
 	if (error)