linux/drivers/scsi/pm8001
Salomon Dushimirimana 824a7672e3 scsi: pm8001: Fix use-after-free in pm8001_queue_command()
[ Upstream commit 38353c26db ]

Commit e29c47fe89 ("scsi: pm8001: Simplify pm8001_task_exec()") refactors
pm8001_queue_command(), however it introduces a potential cause of a double
free scenario when it changes the function to return -ENODEV in case of phy
down/device gone state.

In this path, pm8001_queue_command() updates task status and calls
task_done to indicate to upper layer that the task has been handled.
However, this also frees the underlying SAS task. A -ENODEV is then
returned to the caller. When libsas sas_ata_qc_issue() receives this error
value, it assumes the task wasn't handled/queued by LLDD and proceeds to
clean up and free the task again, resulting in a double free.

Since pm8001_queue_command() handles the SAS task in this case, it should
return 0 to the caller indicating that the task has been handled.

Fixes: e29c47fe89 ("scsi: pm8001: Simplify pm8001_task_exec()")
Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://patch.msgid.link/20260213192806.439432-1-salomondush@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-12 07:09:10 -04:00
..
Makefile scsi: pm80xx: Add tracepoints 2021-11-18 22:26:58 -05:00
pm80xx_hwi.c scsi: pm80xx: Add helper function to get the local phy id 2025-08-18 22:08:30 -04:00
pm80xx_hwi.h scsi: pm80xx: Avoid -Wflex-array-member-not-at-end warnings 2025-09-09 22:40:32 -04:00
pm80xx_tracepoints.c scsi: pm80xx: Add tracepoints 2021-11-18 22:26:58 -05:00
pm80xx_tracepoints.h scsi: pm80xx: Add pm80xx_mpi_build_cmd() tracepoint 2021-11-18 22:26:58 -05:00
pm8001_chips.h [SCSI] pm8001: fix endian issue with code optimization. 2012-02-29 16:54:09 -06:00
pm8001_ctl.c scsi: pm8001: Use int instead of u32 to store error codes 2025-08-30 21:37:53 -04:00
pm8001_ctl.h scsi: pm8001: Clean up white space 2021-04-12 23:21:26 -04:00
pm8001_defs.h scsi: pm80xx: Increase reserved tags from 8 to 128 2024-12-04 14:46:58 -05:00
pm8001_hwi.c scsi: pm80xx: Add helper function to get the local phy id 2025-08-18 22:08:30 -04:00
pm8001_hwi.h scsi: pm80xx: Avoid -Wflex-array-member-not-at-end warnings 2025-09-09 22:40:32 -04:00
pm8001_init.c scsi: pm80xx: Fix race condition caused by static variables 2025-08-25 22:20:07 -04:00
pm8001_sas.c scsi: pm8001: Fix use-after-free in pm8001_queue_command() 2026-03-12 07:09:10 -04:00
pm8001_sas.h scsi: pm80xx: Fix race condition caused by static variables 2025-08-25 22:20:07 -04:00