Re: [PATCH] block: add protection for divide by zero in blk_mq_map_queues

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

 



On 5/14/21 11:16 AM, Yiyuan GUO wrote:
> In function blk_mq_map_queues, qmap->nr_queues may equal zero
> and thus it needs to be checked before we pass it to function
> queue_index.
> 
> Signed-off-by: Yiyuan GUO <yguoaz@xxxxxxxxxx>
> ---
>  block/blk-mq-cpumap.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
> index 3db84d319..dc440870e 100644
> --- a/block/blk-mq-cpumap.c
> +++ b/block/blk-mq-cpumap.c
> @@ -65,7 +65,8 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap)
>  		} else {
>  			first_sibling = get_first_sibling(cpu);
>  			if (first_sibling == cpu)
> -				map[cpu] = queue_index(qmap, nr_queues, q++);
> +				if (nr_queues)
> +					map[cpu] = queue_index(qmap, nr_queues, q++);
>  			else
>  				map[cpu] = map[first_sibling];
>  		}
> 
Err ... and what is the value of 'map[cpu]' if 'nr_queues' equals zero?
Please move the 'if (nr_queues)' condition into the first if-clause:

if ((first_sibling == cpu) && nr_queues)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		        Kernel Storage Architect
hare@xxxxxxx			               +49 911 74053 688
SUSE Software Solutions Germany GmbH, 90409 Nürnberg
GF: F. Imendörffer, HRB 36809 (AG Nürnberg)



[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