]> Git Repo - linux.git/commitdiff
scsi: enclosure: Fix stale device oops with hot replug
authorJames Bottomley <[email protected]>
Thu, 9 Jan 2020 01:21:32 +0000 (17:21 -0800)
committerMartin K. Petersen <[email protected]>
Fri, 10 Jan 2020 06:38:40 +0000 (01:38 -0500)
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: 43d8eb9cfd0a ("[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]>
drivers/misc/enclosure.c

index 6d27ccfe068021127efd5452d7ff872859bcbe5f..3c2d405bc79b951f88a618289bfc8d47e16fac52 100644 (file)
@@ -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;
This page took 0.053676 seconds and 4 git commands to generate.