lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
 
-       /* The sdev is not guaranteed to be valid post scsi_done upcall. */
-       cmd->scsi_done(cmd);
-
        spin_lock_irqsave(&phba->hbalock, flags);
        lpfc_cmd->pCmd = NULL;
        spin_unlock_irqrestore(&phba->hbalock, flags);
 
+       /* The sdev is not guaranteed to be valid post scsi_done upcall. */
+       cmd->scsi_done(cmd);
+
        /*
         * If there is a thread waiting for command completion
         * wake up the thread.
 
 
        if (iotag != 0 && iotag <= phba->sli.last_iotag) {
                cmd_iocb = phba->sli.iocbq_lookup[iotag];
-               list_del_init(&cmd_iocb->list);
                if (cmd_iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ) {
+                       /* remove from txcmpl queue list */
+                       list_del_init(&cmd_iocb->list);
                        cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ;
+                       return cmd_iocb;
                }
-               return cmd_iocb;
        }
 
        lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
-                       "0317 iotag x%x is out off "
+                       "0317 iotag x%x is out of "
                        "range: max iotag x%x wd0 x%x\n",
                        iotag, phba->sli.last_iotag,
                        *(((uint32_t *) &prspiocb->iocb) + 7));
                        return cmd_iocb;
                }
        }
+
        lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
-                       "0372 iotag x%x is out off range: max iotag (x%x)\n",
+                       "0372 iotag x%x is out of range: max iotag (x%x)\n",
                        iotag, phba->sli.last_iotag);
        return NULL;
 }
        /* Look up the ELS command IOCB and create pseudo response IOCB */
        cmdiocbq = lpfc_sli_iocbq_lookup_by_tag(phba, pring,
                                bf_get(lpfc_wcqe_c_request_tag, wcqe));
+       /* Put the iocb back on the txcmplq */
+       lpfc_sli_ringtxcmpl_put(phba, pring, cmdiocbq);
        spin_unlock_irqrestore(&pring->ring_lock, iflags);
 
        if (unlikely(!cmdiocbq)) {