Commit 7b2ef1a
scsi: hpsa: Fix potential memory leak in hpsa_big_passthru_ioctl()
commit b812965 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: edd1636 ("[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>1 parent 305b1a3 commit 7b2ef1a
1 file changed
+12
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6528 | 6528 | | |
6529 | 6529 | | |
6530 | 6530 | | |
6531 | | - | |
6532 | | - | |
6533 | | - | |
6534 | | - | |
6535 | | - | |
| 6531 | + | |
6536 | 6532 | | |
6537 | | - | |
6538 | | - | |
| 6533 | + | |
| 6534 | + | |
| 6535 | + | |
6539 | 6536 | | |
6540 | 6537 | | |
6541 | | - | |
6542 | | - | |
| 6538 | + | |
| 6539 | + | |
| 6540 | + | |
| 6541 | + | |
| 6542 | + | |
| 6543 | + | |
| 6544 | + | |
| 6545 | + | |
6543 | 6546 | | |
6544 | 6547 | | |
6545 | 6548 | | |
| |||
0 commit comments