Message ID | YtEhCjDq2oe2SIkS@kili (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] null_blk: prevent NULL dereference in null_init_tag_set() | expand |
Hello Dan, On Fri, Jul 15, 2022 at 11:10:50AM +0300, Dan Carpenter wrote: > 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> FYI, I have posted another fix/cleanup for this issue: https://lore.kernel.org/linux-block/20220715031916.151469-1-ming.lei@redhat.com/T/#u Thanks, Ming
On Fri, 15 Jul 2022 11:10:50 +0300, Dan Carpenter wrote: > 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) > > Applied, thanks! [2/2] null_blk: fix ida error handling in null_add_dev() commit: 8c740c6bf12dec03b6f35b19fe6c183929d0b88a Best regards,
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)
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(-)