From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jens Axboe <axboe@kernel.dk>, Vincent Fu <vincent.fu@samsung.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Ming Lei <ming.lei@redhat.com>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] null_blk: prevent NULL dereference in null_init_tag_set()
Date: Fri, 15 Jul 2022 11:10:50 +0300 [thread overview]
Message-ID: <YtEhCjDq2oe2SIkS@kili> (raw)
The "nullb" pointer can be NULL. Smatch prints a warning about this:
drivers/block/null_blk/main.c:1914 null_init_tag_set()
error: we previously assumed 'nullb' could be null (see line 1911)
Fixes: 37ae152c7a0d ("null_blk: add configfs variables for 2 options")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/block/null_blk/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 67c17e5d2c99..016ec3a2f98f 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1911,9 +1911,9 @@ static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set *set)
set->numa_node = nullb ? nullb->dev->home_node : g_home_node;
set->cmd_size = sizeof(struct nullb_cmd);
set->flags = BLK_MQ_F_SHOULD_MERGE;
- if (nullb->dev->no_sched)
+ if (nullb && nullb->dev->no_sched)
set->flags |= BLK_MQ_F_NO_SCHED;
- if (nullb->dev->shared_tag_bitmap)
+ if (nullb && nullb->dev->shared_tag_bitmap)
set->flags |= BLK_MQ_F_TAG_HCTX_SHARED;
set->driver_data = nullb;
if (poll_queues)
--
2.35.1
next reply other threads:[~2022-07-15 8:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 8:10 Dan Carpenter [this message]
2022-07-15 8:12 ` [PATCH 2/2] null_blk: fix ida error handling in null_add_dev() Dan Carpenter
2022-07-15 8:23 ` Johannes Thumshirn
2022-07-15 9:14 ` Dan Carpenter
2022-07-15 9:26 ` [PATCH 1/2] null_blk: prevent NULL dereference in null_init_tag_set() Ming Lei
2022-07-15 15:05 ` (subset) " Jens Axboe
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=YtEhCjDq2oe2SIkS@kili \
--to=dan.carpenter@oracle.com \
--cc=axboe@kernel.dk \
--cc=damien.lemoal@opensource.wdc.com \
--cc=johannes.thumshirn@wdc.com \
--cc=kch@nvidia.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=shinichiro.kawasaki@wdc.com \
--cc=vincent.fu@samsung.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