linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] enclosure: Fix stale device oops with hot replug
@ 2020-01-09  1:21 James Bottomley
  2020-01-10  6:39 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2020-01-09  1:21 UTC (permalink / raw)
  To: linux-scsi; +Cc: Luo Jiaxing, John Garry

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.

Fixes: 43d8eb9cfd0a ("[SCSI] ses: add support for enclosure component hot removal")
Reported-by: Luo Jiaxing 
Tested-by: John Garry 
Signed-off-by: James Bottomley 
---
 drivers/misc/enclosure.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 6d27ccfe0680..3c2d405bc79b 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -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;
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] enclosure: Fix stale device oops with hot replug
  2020-01-09  1:21 [PATCH] enclosure: Fix stale device oops with hot replug James Bottomley
@ 2020-01-10  6:39 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2020-01-10  6:39 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Luo Jiaxing, John Garry


James,

> 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.

Applied to 5.5/scsi-fixes...

> Fixes: 43d8eb9cfd0a ("[SCSI] ses: add support for enclosure component hot removal")
> Reported-by: Luo Jiaxing 
> Tested-by: John Garry 
> Signed-off-by: James Bottomley 

...and filled out the blanks.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-10  6:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  1:21 [PATCH] enclosure: Fix stale device oops with hot replug James Bottomley
2020-01-10  6:39 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).