All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: linux-scsi <linux-scsi@vger.kernel.org>
Cc: Luo Jiaxing <luojiaxing@huawei.com>, John Garry <john.garry@huawei.com>
Subject: [PATCH] enclosure: Fix stale device oops with hot replug
Date: Wed, 08 Jan 2020 17:21:32 -0800	[thread overview]
Message-ID: <1578532892.3852.10.camel@HansenPartnership.com> (raw)

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


             reply	other threads:[~2020-01-09  1:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09  1:21 James Bottomley [this message]
2020-01-10  6:39 ` [PATCH] enclosure: Fix stale device oops with hot replug Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1578532892.3852.10.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=john.garry@huawei.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luojiaxing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.