[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f9a07f10-9d9d-de94-64b9-acf722cea8cd@suse.de>
Date: Wed, 2 Mar 2022 18:11:29 +0800
From: Coly Li <colyli@...e.de>
To: Jia-Ju Bai <baijiaju1990@...il.com>
Cc: linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org,
kent.overstreet@...il.com
Subject: Re: [PATCH] md: bcache: check the return value of kzalloc() in
detached_dev_do_request()
On 2/25/22 4:20 PM, Jia-Ju Bai wrote:
> The function kzalloc() in detached_dev_do_request() can fail, so its
> return value should be checked.
>
> Fixes: bc082a55d25c (bcache: fix inaccurate io state for detached bcache devices)
> Reported-by: TOTE Robot <oslab@...nghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
> ---
> drivers/md/bcache/request.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index d15aae6c51c1..1b5ccfa93b8c 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1107,6 +1107,8 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
> * which would call closure_get(&dc->disk.cl)
> */
> ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
Yes this is a potential problem, may result NULL pointer deference.
> + if (!ddip)
> + return;
The fix here is incorrect. A proper way to fix might be something like this,
if (!ddip) {
bio->bi_status = BLK_STS_RESOURCE;
bio->bi_end_io(bio);
return;
}
The orignal patch will make I/O task be in sleep forever.
> ddip->d = d;
> /* Count on the bcache device */
> ddip->orig_bdev = orig_bdev;
Powered by blists - more mailing lists