• Shaohua Li's avatar
    block/nullb: fix NULL dereference · 0d06a42f
    Shaohua Li authored
    Dan reported this:
    
    The patch 2984c868: "nullb: factor disk parameters" from Aug 14,
    2017, leads to the following Smatch complaint:
    
    drivers/block/null_blk.c:1759 null_init_tag_set()
    	 error: we previously assumed 'nullb' could be null (see line
    1750)
    
      1755		set->cmd_size	= sizeof(struct nullb_cmd);
      1756		set->flags = BLK_MQ_F_SHOULD_MERGE;
      1757		set->driver_data = NULL;
      1758
      1759		if (nullb->dev->blocking)
                        ^^^^^^^^^^^^^^^^^^^^
    And an unchecked dereference.
    
    nullb could be NULL here.
    Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: default avatarShaohua Li <shli@fb.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    0d06a42f
null_blk.c 48 KB