Merge tag 'powerpc-4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[cascardo/linux.git] / drivers / scsi / bnx2fc / bnx2fc_io.c
index 2230dab..026f394 100644 (file)
@@ -179,12 +179,24 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, int err_code)
 
        bnx2fc_unmap_sg_list(io_req);
        io_req->sc_cmd = NULL;
+
+       /* Sanity checks before returning command to mid-layer */
        if (!sc_cmd) {
                printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. "
                                    "IO(0x%x) already cleaned up\n",
                       io_req->xid);
                return;
        }
+       if (!sc_cmd->device) {
+               pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
+               return;
+       }
+       if (!sc_cmd->device->host) {
+               pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n",
+                   io_req->xid);
+               return;
+       }
+
        sc_cmd->result = err_code << 16;
 
        BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
@@ -770,7 +782,7 @@ retry_tmf:
        spin_unlock_bh(&tgt->tgt_lock);
 
        rc = wait_for_completion_timeout(&io_req->tm_done,
-                                        BNX2FC_TM_TIMEOUT * HZ);
+                                        interface->tm_timeout * HZ);
        spin_lock_bh(&tgt->tgt_lock);
 
        io_req->wait_for_comp = 0;