From: Anand Jain <anand.jain@oracle.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [bug report] btrfs: add helper function check device delete able
Date: Fri, 20 Jul 2018 14:36:25 +0800 [thread overview]
Message-ID: <9f9bd2fa-fd82-79e1-0846-1871f416661e@oracle.com> (raw)
In-Reply-To: <20180719080855.xytzxnj5vfvabipj@mwanda>
Noted. Thanks Dan.
-Anand
On 07/19/2018 04:10 PM, Dan Carpenter wrote:
> Hello Anand Jain,
>
> The patch a6500c9ef8ac: "btrfs: add helper function check device
> delete able" from Jul 10, 2018, leads to the following static checker
> warning:
>
> fs/btrfs/volumes.c:1871 btrfs_device_delete_able()
> error: passing non negative 4 to ERR_PTR
>
> fs/btrfs/volumes.c:1876 btrfs_device_delete_able()
> error: passing non negative 6 to ERR_PTR
>
> fs/btrfs/volumes.c:1879 btrfs_device_delete_able()
> error: passing non negative 5 to ERR_PTR
>
> fs/btrfs/volumes.c:1883 btrfs_device_delete_able()
> error: passing non negative 7 to ERR_PTR
>
> fs/btrfs/volumes.c
> 1861 static struct btrfs_device *btrfs_device_delete_able(
> 1862 struct btrfs_fs_info *fs_info,
> 1863 const char *device_path, u64 devid)
> 1864 {
> 1865 int ret;
> 1866 struct btrfs_device *device;
> 1867
> 1868 ret = btrfs_check_raid_min_devices(fs_info,
> 1869 btrfs_num_devices(fs_info) - 1);
> 1870 if (ret)
> 1871 return ERR_PTR(ret);
> ^^^
> This is a btrfs_err_code enum, not a negative error code. It leads to
> a NULL dereference in the caller.
>
> 1872
> 1873 ret = btrfs_find_device_by_devspec(fs_info, devid, device_path,
> 1874 &device);
> 1875 if (ret)
> 1876 return ERR_PTR(ret);
> ^^^
> 1877
> 1878 if (test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state))
> 1879 return ERR_PTR(BTRFS_ERROR_DEV_TGT_REPLACE);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Same only even more so.
>
> 1880
> 1881 if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) &&
> 1882 fs_info->fs_devices->rw_devices == 1)
> 1883 return ERR_PTR(BTRFS_ERROR_DEV_ONLY_WRITABLE);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 1884
> 1885 return device;
> 1886 }
>
> See also:
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2018-07-20 7:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-19 8:10 [bug report] btrfs: add helper function check device delete able Dan Carpenter
2018-07-20 6:36 ` Anand Jain [this message]
Reply instructions:
You may reply publicly 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=9f9bd2fa-fd82-79e1-0846-1871f416661e@oracle.com \
--to=anand.jain@oracle.com \
--cc=dan.carpenter@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).