RE: [PATCH] null_blk: cleanup null_init_tag_set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Ming Lei [mailto:ming.lei@xxxxxxxxxx]
> Sent: Thursday, July 14, 2022 11:19 PM
> To: Jens Axboe <axboe@xxxxxxxxx>
> Cc: linux-block@xxxxxxxxxxxxxxx; Ming Lei <ming.lei@xxxxxxxxxx>;
> Vincent Fu <vincent.fu@xxxxxxxxxxx>
> Subject: [PATCH] null_blk: cleanup null_init_tag_set
> 
> The passed 'nullb' can be NULL, so cause null ptr reference.
> 
> Fix the issue, meantime cleanup null_init_tag_set for avoiding to add
> similar issue in future.
> 
> Cc: Vincent Fu <vincent.fu@xxxxxxxxxxx>
> Fixes: 37ae152c7a0d ("null_blk: add configfs variables for 2 options")
> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> ---
>  drivers/block/null_blk/main.c | 49 ++++++++++++++++++++++-----------
> --
>  1 file changed, 31 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index c955a07dba2d..a08856b121b3 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -1898,31 +1898,44 @@ static int null_gendisk_register(struct nullb
> *nullb)
> 
>  static int null_init_tag_set(struct nullb *nullb, struct blk_mq_tag_set
> *set)
>  {
> +	unsigned int flags = BLK_MQ_F_SHOULD_MERGE;
> +	int hw_queues, numa_node;
> +	unsigned int queue_depth;
>  	int poll_queues;
> 
> +	if (nullb) {
> +		hw_queues = nullb->dev->submit_queues;
> +		poll_queues = nullb->dev->poll_queues;
> +		queue_depth = nullb->dev->hw_queue_depth;
> +		numa_node = nullb->dev->home_node;
> +		if (nullb->dev->no_sched)
> +			flags |= BLK_MQ_F_NO_SCHED;
> +		if (nullb->dev->shared_tag_bitmap)
> +			flags |= BLK_MQ_F_TAG_HCTX_SHARED;
> +		if (nullb->dev->blocking)
> +			flags |= BLK_MQ_F_BLOCKING;
> +	} else {
> +		hw_queues = g_submit_queues;
> +		poll_queues = g_poll_queues;
> +		queue_depth = g_hw_queue_depth;
> +		numa_node = g_home_node;
> +		if (g_blocking)
> +			flags |= BLK_MQ_F_BLOCKING;
> +	}
> +

Ming, thank you for fixing the mess I created.

I believe that even when 'nullb' is NULL we should still set the
BLK_MQ_F_NO_SCHED and BLK_MQ_F_TAG_HCTX_SHARED flags based on the values of
g_no_sched and g_shared_tag_bitmap, respectively. Is that not right?

Vincent




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux