]> Gentwo Git Trees - linux/.git/commit
scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 19 Sep 2025 09:26:37 +0000 (11:26 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 25 Sep 2025 01:27:00 +0000 (21:27 -0400)
commitb81296591c567b12d3873b05a37b975707959b94
tree5213adc2a32e52798d3642fa52e4018400c53bc6
parent88e8acffd7af9b030d2772f27ee30639be7024cf
scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()

Replace kmalloc() followed by copy_from_user() with memdup_user() to fix
a memory leak that occurs when copy_from_user(buff[sg_used],,) fails and
the 'cleanup1:' path does not free the memory for 'buff[sg_used]'. Using
memdup_user() avoids this by freeing the memory internally.

Since memdup_user() already allocates memory, use kzalloc() in the else
branch instead of manually zeroing 'buff[sg_used]' using memset(0).

Cc: stable@vger.kernel.org
Fixes: edd163687ea5 ("[SCSI] hpsa: add driver for HP Smart Array controllers.")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/hpsa.c