From: Khazhismel Kumykov <khazhy@chromium.org>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Gabriel Krisman Bertazi <krisman@collabora.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Khazhismel Kumykov <khazhy@google.com>
Subject: [PATCH] scsi: fix crash in scsi_remove_host after alloc failure
Date: Mon, 17 Oct 2022 10:11:47 -0700 [thread overview]
Message-ID: <20221017171147.3300575-1-khazhy@google.com> (raw)
If transport_register_device returns error, shost_gendev has already
been cleaned up - however since we ignore the error device setup
continues happily. We will eventually call transport_unregister_device,
attempting to delete shost_gendev again, resulting in a crash.
It looks like when this cleanup behavior was added, iscsi was updated,
but scsi was missed.
Fixes: cd7ea70bb00a ("scsi: drivers: base: Propagate errors through the transport component")
Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
---
drivers/scsi/scsi_sysfs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index c95177ca6ed2..722ab042fbd7 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1599,7 +1599,11 @@ EXPORT_SYMBOL(scsi_register_interface);
**/
int scsi_sysfs_add_host(struct Scsi_Host *shost)
{
- transport_register_device(&shost->shost_gendev);
+ int err;
+
+ err = transport_register_device(&shost->shost_gendev);
+ if (err)
+ return err;
transport_configure_device(&shost->shost_gendev);
return 0;
}
--
2.38.0.413.g74048e4d9e-goog
next reply other threads:[~2022-10-17 17:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 17:11 Khazhismel Kumykov [this message]
2022-10-18 16:47 ` [PATCH] scsi: fix crash in scsi_remove_host after alloc failure Mike Christie
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=20221017171147.3300575-1-khazhy@google.com \
--to=khazhy@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jejb@linux.ibm.com \
--cc=khazhy@google.com \
--cc=krisman@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox