From: Mike Christie Date: Wed, 10 Feb 2010 22:51:44 +0000 (-0600) Subject: [SCSI] cxgb3i: check for setup netdev X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9010b94636312c7fb12b591ef09e915f8f80bbd5;p=linux-beck.git [SCSI] cxgb3i: check for setup netdev If the netdev has not been setup when the host is, we will oops when the iscsi layer calls into the driver and a it tries to reference the netdev in hba->ndev. This can happen if the iscsi driver is loaded before ifup is done. This patch just adds a check, so we can gracefully fail the operation. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c index 1fd89b229c87..412853c65372 100644 --- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c +++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c @@ -708,6 +708,12 @@ static int cxgb3i_host_set_param(struct Scsi_Host *shost, { struct cxgb3i_hba *hba = iscsi_host_priv(shost); + if (!hba->ndev) { + shost_printk(KERN_ERR, shost, "Could not set host param. " + "Netdev for host not set.\n"); + return -ENODEV; + } + cxgb3i_api_debug("param %d, buf %s.\n", param, buf); switch (param) { @@ -738,6 +744,12 @@ static int cxgb3i_host_get_param(struct Scsi_Host *shost, struct cxgb3i_hba *hba = iscsi_host_priv(shost); int len = 0; + if (!hba->ndev) { + shost_printk(KERN_ERR, shost, "Could not set host param. " + "Netdev for host not set.\n"); + return -ENODEV; + } + cxgb3i_api_debug("hba %s, param %d.\n", hba->ndev->name, param); switch (param) {