Commit b518e86
scsi: smartpqi: Fix device resources accessed after device removal
Correct possible race conditions during device removal.
Previously, a scheduled work item to reset a LUN could still execute
after the device was removed, leading to use-after-free and other
resource access issues.
This race condition occurs because the abort handler may schedule a LUN
reset concurrently with device removal via sdev_destroy(), leading to
use-after-free and improper access to freed resources.
- Check in the device reset handler if the device is still present in
the controller's SCSI device list before running; if not, the reset
is skipped.
- Cancel any pending TMF work that has not started in sdev_destroy().
- Ensure device freeing in sdev_destroy() is done while holding the
LUN reset mutex to avoid races with ongoing resets.
Fixes: 2d80f40 ("scsi: smartpqi: Update deleting a LUN via sysfs")
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Signed-off-by: Mike McGowen <mike.mcgowen@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
Link: https://patch.msgid.link/20251106163823.786828-3-don.brace@microchip.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>1 parent f3ecbba commit b518e86
1 file changed
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6427 | 6427 | | |
6428 | 6428 | | |
6429 | 6429 | | |
| 6430 | + | |
6430 | 6431 | | |
6431 | 6432 | | |
6432 | 6433 | | |
6433 | 6434 | | |
| 6435 | + | |
| 6436 | + | |
| 6437 | + | |
| 6438 | + | |
| 6439 | + | |
| 6440 | + | |
| 6441 | + | |
| 6442 | + | |
| 6443 | + | |
| 6444 | + | |
| 6445 | + | |
6434 | 6446 | | |
6435 | 6447 | | |
6436 | 6448 | | |
| |||
6611 | 6623 | | |
6612 | 6624 | | |
6613 | 6625 | | |
| 6626 | + | |
6614 | 6627 | | |
| 6628 | + | |
6615 | 6629 | | |
6616 | 6630 | | |
6617 | 6631 | | |
| |||
6638 | 6652 | | |
6639 | 6653 | | |
6640 | 6654 | | |
| 6655 | + | |
| 6656 | + | |
| 6657 | + | |
| 6658 | + | |
6641 | 6659 | | |
6642 | 6660 | | |
| 6661 | + | |
6643 | 6662 | | |
6644 | 6663 | | |
6645 | 6664 | | |
| |||
0 commit comments