@@ -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)
@@ -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);
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(-)