[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7b796b3e-2fd9-00bc-5410-1097512162be@suse.de>
Date: Fri, 8 Apr 2022 01:18:20 +0800
From: Coly Li <colyli@...e.de>
To: Jia-Ju Bai <baijiaju1990@...il.com>
Cc: linux-bcache@...r.kernel.org, kent.overstreet@...il.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] md: bcache: check the return value of kzalloc() in
detached_dev_do_request()
On 3/3/22 9:55 AM, 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>
> ---
> v2:
> * Fix the error handling code when ddip is NULL.
> Thank Coly for good advice.
>
> ---
> drivers/md/bcache/request.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index d15aae6c51c1..673a680240a9 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1107,6 +1107,12 @@ 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);
> + if (!ddip) {
> + bio->bi_status = BLK_STS_RESOURCE;
> + bio->bi_end_io(bio);
> + return;
> + }
> +
> ddip->d = d;
> /* Count on the bcache device */
> ddip->orig_bdev = orig_bdev;
Added into my testing queue.
Thanks.
Coly Li
Powered by blists - more mailing lists