From: QintaoShen <unSimple1993@163.com>
To: colyli@suse.de
Cc: linux-bcache@vger.kernel.org, kent.overstreet@gmail.com,
linux-kernel@vger.kernel.org, QintaoShen <unSimple1993@163.com>
Subject: [PATCH v1] bcache: Check for NULL return of kzalloc()
Date: Thu, 24 Mar 2022 17:27:54 +0800 [thread overview]
Message-ID: <1648114074-10045-1-git-send-email-unSimple1993@163.com> (raw)
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 ;
+
ddip->d = d;
/* Count on the bcache device */
ddip->orig_bdev = orig_bdev;
--
2.7.4
next reply other threads:[~2022-03-24 9:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-24 9:27 QintaoShen [this message]
2022-04-07 16:59 ` [PATCH v1] bcache: Check for NULL return of kzalloc() Coly Li
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=1648114074-10045-1-git-send-email-unSimple1993@163.com \
--to=unsimple1993@163.com \
--cc=colyli@suse.de \
--cc=kent.overstreet@gmail.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@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).