]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:23:15 +0000 (16:23 +0200)
commit52f37ce2d523959e8a2a1a135c869f72044ecb15
tree43eae7d8f508895c744bd2aacde04e3c91336c56
parent77a5786c26903b11e3161be4c48c3027c622f140
scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()

commit b81296591c567b12d3873b05a37b975707959b94 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/hpsa.c