public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Use kmalloc_array to prevent overflow of dynamic size calculation
@ 2025-10-01 11:39 Bhanu Seshu Kumar Valluri
  2025-10-03 14:12 ` Don.Brace
  2025-10-03 14:53 ` James Bottomley
  0 siblings, 2 replies; 6+ messages in thread
From: Bhanu Seshu Kumar Valluri @ 2025-10-01 11:39 UTC (permalink / raw)
  To: Don Brace, James E . J . Bottomley, Martin K . Petersen,
	storagedev
  Cc: linux-scsi, linux-kernel-mentees, skhan, david.hunter.linux,
	bhanuseshukumar

Use kmalloc_array to avoid potential overflow during dynamic size calculation
inside kmalloc.

Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 125944941601..7ff39f1faf38 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -8937,7 +8937,7 @@ 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;
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-07  6:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-01 11:39 [PATCH] scsi: Use kmalloc_array to prevent overflow of dynamic size calculation Bhanu Seshu Kumar Valluri
2025-10-03 14:12 ` Don.Brace
2025-10-03 14:53 ` James Bottomley
2025-10-04  4:25   ` Bhanu Seshu Kumar Valluri
2025-10-06 11:28     ` Niklas Cassel
2025-10-07  6:18       ` Bhanu Seshu Kumar Valluri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox