Skip to content

Commit

Permalink
[SCSI] cxgb3i: check for setup netdev
Browse files Browse the repository at this point in the history
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 <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Mike Christie authored and James Bottomley committed Feb 17, 2010
1 parent d9573e7 commit 9010b94
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/scsi/cxgb3i/cxgb3i_iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9010b94

Please sign in to comment.