Re: [PATCH] scsi: qedf: Use kzalloc() and add check for bdt_info

Bart Van Assche
2025-01-31T20:32:33Z

On 1/31/25 11:54 AM, Jiasheng Jiang wrote:
> - cmgr->io_bdt_pool = kmalloc_array(num_ios, sizeof(struct io_bdt *),
> - GFP_KERNEL);
> + cmgr->io_bdt_pool = kzalloc(num_ios * sizeof(struct io_bdt *), GFP_KERNEL);

Please do not reintroduce the possibility of multiplication overflow.
What is wrong with adding __GFP_ZERO to the second kmalloc_array()
argument or with using kcalloc()? From include/linux/slab.h:

#define kcalloc(n, size, flags) kmalloc_array(n, size, (flags) | __GFP_ZERO)

Thanks,

Bart.