From: Coly Li <colyli@suse.de>
To: QintaoShen <unSimple1993@163.com>
Cc: linux-bcache@vger.kernel.org, kent.overstreet@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] bcache: Check for NULL return of kzalloc()
Date: Fri, 8 Apr 2022 00:59:34 +0800 [thread overview]
Message-ID: <c934c457-fe8f-7937-f348-eccf46375878@suse.de> (raw)
In-Reply-To: <1648114074-10045-1-git-send-email-unSimple1993@163.com>
On 3/24/22 5:27 PM, QintaoShen wrote:
> kzalloc() is a memory allocation function which may return a NULL pointer.
> Therefore, it is better to check the return value of kzalloc() to avoid potential
> NULL-pointer dereference.
>
> Signed-off-by: QintaoShen <unSimple1993@163.com>
> ---
> drivers/md/bcache/request.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index fdd0194..232ffe3 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -1105,6 +1105,9 @@ 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 (!ddpp)
> + return ;
This is wrong. If you test your patch, you may experience a system hang
I guess.
Coly Li
> +
> ddip->d = d;
> /* Count on the bcache device */
> ddip->orig_bdev = orig_bdev;
prev parent reply other threads:[~2022-04-07 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 9:27 [PATCH v1] bcache: Check for NULL return of kzalloc() QintaoShen
2022-04-07 16:59 ` Coly Li [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=c934c457-fe8f-7937-f348-eccf46375878@suse.de \
--to=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=unSimple1993@163.com \
/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).