enclosure: Fix stale device oops with hot replug
Subsystems (2)
James Bottomley
maintainerPATCH 1/1 enclosure: Fix stale device oops with hot replug
Doing an add/remove/add on a SCSI device in an enclosure leads to an oops caused by poisoned values in the enclosure device list pointers. The reason is because we are keeping the enclosure device across the enclosed device add/remove/add but the current code is doing a device_add/device_del/device_add on it. This is the wrong thing to do in sysfs, so fix it by not doing a device_del on the enclosure device simply because of a hot remove of the drive in the slot.
--- drivers/misc/enclosure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/enclosure.c +1 -2
@@ -406,10 +406,9 @@ int enclosure_remove_device(struct enclosure_device *edev, struct device *dev) cdev = &edev->component[i];if (cdev->dev == dev) {enclosure_remove_links (cdev); -device_del (&cdev->cdev);put_device (dev); cdev->dev =NULL ; -return device_add (&cdev->cdev); +return 0 ; } }return -ENODEV ;
Signature · 1 line
2.16.4
Martin K. Petersen
AppliedJames,
Quoted 7 lines
Doing an add/remove/add on a SCSI device in an enclosure leads to an oops caused by poisoned values in the enclosure device list pointers. The reason is because we are keeping the enclosure device across the enclosed device add/remove/add but the current code is doing a device_add/device_del/device_add on it. This is the wrong thing to do in sysfs, so fix it by not doing a
device_delon the enclosure device simply because of a hot remove of the drive in the slot.
Applied to 5.5/scsi-fixes...
Quoted 4 lines
Fixes 43d8eb9cfd0a ("[SCSI] ses: add support for enclosure component hot removal")Reported-by Luo JiaxingTested-by John GarrySigned-off-by James Bottomley
...and filled out the blanks.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering