Skip to content

Commit 529244b

Browse files
James Bottomleymartinkpetersen
authored andcommitted
scsi: 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. [mkp: added missing email addresses] Fixes: 43d8eb9 ("[SCSI] ses: add support for enclosure component hot removal") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: James Bottomley <[email protected]> Reported-by: Luo Jiaxing <[email protected]> Tested-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 465f4ed commit 529244b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/misc/enclosure.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,9 @@ int enclosure_remove_device(struct enclosure_device *edev, struct device *dev)
406406
cdev = &edev->component[i];
407407
if (cdev->dev == dev) {
408408
enclosure_remove_links(cdev);
409-
device_del(&cdev->cdev);
410409
put_device(dev);
411410
cdev->dev = NULL;
412-
return device_add(&cdev->cdev);
411+
return 0;
413412
}
414413
}
415414
return -ENODEV;

0 commit comments

Comments
 (0)