Re: [PATCH] scsi: qedf: Use kzalloc() and add check for bdt_info
From: Bart Van Assche
Date: Fri Jan 31 2025 - 15:32:42 EST
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.