]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: smartpqi: Prefer kmalloc_array() over kmalloc()
authorBhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
Tue, 7 Oct 2025 06:53:45 +0000 (12:23 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 20 Oct 2025 16:01:20 +0000 (12:01 -0400)
As a best practice use kmalloc_array() to safely calculate dynamic
object sizes without overflow.

[mkp: line exceeding 100 chars, added newline]

Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
Link: https://patch.msgid.link/20251007065345.8853-1-bhanuseshukumar@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/smartpqi/smartpqi_init.c

index 03c97e60d36f630140f9cfcac431d48767dcb8b3..b5e71ff26e8e16fb4f41c5eca44354eaf1cb36a0 100644 (file)
@@ -8936,7 +8936,8 @@ static int pqi_host_alloc_mem(struct pqi_ctrl_info *ctrl_info,
        if (sg_count == 0 || sg_count > PQI_HOST_MAX_SG_DESCRIPTORS)
                goto out;
 
-       host_memory_descriptor->host_chunk_virt_address = kmalloc(sg_count * sizeof(void *), GFP_KERNEL);
+       host_memory_descriptor->host_chunk_virt_address =
+               kmalloc_array(sg_count, sizeof(void *), GFP_KERNEL);
        if (!host_memory_descriptor->host_chunk_virt_address)
                goto out;