public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: fix crash in scsi_remove_host after alloc failure
@ 2022-10-17 17:11 Khazhismel Kumykov
  2022-10-18 16:47 ` Mike Christie
  0 siblings, 1 reply; 2+ messages in thread
From: Khazhismel Kumykov @ 2022-10-17 17:11 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Gabriel Krisman Bertazi, Greg Kroah-Hartman, linux-scsi,
	linux-kernel, Khazhismel Kumykov

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


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

end of thread, other threads:[~2022-10-18 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-17 17:11 [PATCH] scsi: fix crash in scsi_remove_host after alloc failure Khazhismel Kumykov
2022-10-18 16:47 ` Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox