diff mbox series

iscsi iser: fix iser, allow virtual endpoints again

Message ID 20230421050521.49903-2-cleech@redhat.com (mailing list archive)
State Superseded
Headers show
Series iscsi iser: fix iser, allow virtual endpoints again | expand

Commit Message

Chris Leech April 21, 2023, 5:05 a.m. UTC
iSER creates endpoints before hosts and sessions, so we need to keep
compatibility with virtual device paths and not always expect a parent
host.

Signed-off-by: Chris Leech <cleech@redhat.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 9 ++++++---
 include/scsi/scsi_transport_iscsi.h | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 41f0de2165e0..b8e451a8c76c 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -189,8 +189,10 @@  static struct net *iscsi_host_net(struct iscsi_cls_host *ihost)
 static struct net *iscsi_endpoint_net(struct iscsi_endpoint *ep)
 {
 	struct Scsi_Host *shost = iscsi_endpoint_to_shost(ep);
-	struct iscsi_cls_host *ihost = shost->shost_data;
-
+	struct iscsi_cls_host *ihost;
+	if (!shost)
+		return &init_net;
+	ihost = shost->shost_data;
 	return iscsi_host_net(ihost);
 }
 
@@ -252,7 +254,8 @@  iscsi_create_endpoint(struct Scsi_Host *shost, int dd_size)
 
 	ep->id = id;
 	ep->dev.class = &iscsi_endpoint_class;
-	ep->dev.parent = &shost->shost_gendev;
+	if (shost)
+		ep->dev.parent = &shost->shost_gendev;
 	dev_set_name(&ep->dev, "ep-%d", id);
 	err = device_register(&ep->dev);
         if (err)
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index d233618a17de..bb6734e900e0 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -293,8 +293,9 @@  struct iscsi_cls_session {
 #define iscsi_session_to_shost(_session) \
 	dev_to_shost(_session->dev.parent)
 
+/* endpoints might not have a parent host (iSER) */
 #define iscsi_endpoint_to_shost(_ep) \
-	dev_to_shost(_ep->dev.parent)
+	dev_to_shost(&_ep->dev)
 
 extern struct net *iscsi_sess_net(struct iscsi_cls_session *session);