Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Al Viro <viro@zeniv.linux.org.uk>, linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: Re: [PATCH] btrfs: oops in device_list_add()
Date: Mon, 28 Jan 2019 19:47:00 +0800
Message-ID: <4b2ff563-c3c4-843b-f0d4-f1527465be20@oracle.com> (raw)
In-Reply-To: <20190127045755.GH2217@ZenIV.linux.org.uk>



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);
>   
> 

  parent reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-27  4:58 Al Viro
2019-01-27 12:59 ` Nikolay Borisov
2019-01-28 11:47 ` Anand Jain [this message]
2019-01-28 15:04 ` David Sterba

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b2ff563-c3c4-843b-f0d4-f1527465be20@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox