* [PATCH] btrfs: oops in device_list_add()
@ 2019-01-27 4:58 Al Viro
2019-01-27 12:59 ` Nikolay Borisov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Al Viro @ 2019-01-27 4:58 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
alloc_fs_devices() can return ERR_PTR(-ENOMEM), so
dereferencing its result before the check for IS_ERR() is
a bad idea...
Fixes: d1a63002829a4
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 85149f27644d..72adc5643bde 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -955,11 +955,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
else
fs_devices = alloc_fs_devices(disk_super->fsid, NULL);
- fs_devices->fsid_change = fsid_change_in_progress;
-
if (IS_ERR(fs_devices))
return ERR_CAST(fs_devices);
+ fs_devices->fsid_change = fsid_change_in_progress;
+
mutex_lock(&fs_devices->device_list_mutex);
list_add(&fs_devices->fs_list, &fs_uuids);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: oops in device_list_add()
2019-01-27 4:58 [PATCH] btrfs: oops in device_list_add() Al Viro
@ 2019-01-27 12:59 ` Nikolay Borisov
2019-01-28 11:47 ` Anand Jain
2019-01-28 15:04 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2019-01-27 12:59 UTC (permalink / raw)
To: Al Viro, linux-btrfs
On 27.01.19 г. 6:58 ч., Al Viro wrote:
> alloc_fs_devices() can return ERR_PTR(-ENOMEM), so
> dereferencing its result before the check for IS_ERR() is
> a bad idea...
>
> Fixes: d1a63002829a4
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Thought this was already fixed, doh...
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> ---
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 85149f27644d..72adc5643bde 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -955,11 +955,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
> else
> fs_devices = alloc_fs_devices(disk_super->fsid, NULL);
>
> - fs_devices->fsid_change = fsid_change_in_progress;
> -
> if (IS_ERR(fs_devices))
> return ERR_CAST(fs_devices);
>
> + fs_devices->fsid_change = fsid_change_in_progress;
> +
> mutex_lock(&fs_devices->device_list_mutex);
> list_add(&fs_devices->fs_list, &fs_uuids);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: oops in device_list_add()
2019-01-27 4:58 [PATCH] btrfs: oops in device_list_add() Al Viro
2019-01-27 12:59 ` Nikolay Borisov
@ 2019-01-28 11:47 ` Anand Jain
2019-01-28 15:04 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Anand Jain @ 2019-01-28 11:47 UTC (permalink / raw)
To: Al Viro, linux-btrfs; +Cc: Nikolay Borisov
On 1/27/19 12:58 PM, Al Viro wrote:
> alloc_fs_devices() can return ERR_PTR(-ENOMEM), so
> dereferencing its result before the check for IS_ERR() is
> a bad idea...
>
> Fixes: d1a63002829a4
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
nice catch.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
> ---
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 85149f27644d..72adc5643bde 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -955,11 +955,11 @@ static noinline struct btrfs_device *device_list_add(const char *path,
> else
> fs_devices = alloc_fs_devices(disk_super->fsid, NULL);
>
> - fs_devices->fsid_change = fsid_change_in_progress;
> -
> if (IS_ERR(fs_devices))
> return ERR_CAST(fs_devices);
>
> + fs_devices->fsid_change = fsid_change_in_progress;
> +
> mutex_lock(&fs_devices->device_list_mutex);
> list_add(&fs_devices->fs_list, &fs_uuids);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: oops in device_list_add()
2019-01-27 4:58 [PATCH] btrfs: oops in device_list_add() Al Viro
2019-01-27 12:59 ` Nikolay Borisov
2019-01-28 11:47 ` Anand Jain
@ 2019-01-28 15:04 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2019-01-28 15:04 UTC (permalink / raw)
To: Al Viro; +Cc: linux-btrfs, Nikolay Borisov
On Sun, Jan 27, 2019 at 04:58:00AM +0000, Al Viro wrote:
> alloc_fs_devices() can return ERR_PTR(-ENOMEM), so
> dereferencing its result before the check for IS_ERR() is
> a bad idea...
>
> Fixes: d1a63002829a4
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Thanks, added to 5.0-rc queue.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-28 15:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-27 4:58 [PATCH] btrfs: oops in device_list_add() Al Viro
2019-01-27 12:59 ` Nikolay Borisov
2019-01-28 11:47 ` Anand Jain
2019-01-28 15:04 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).