linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] lpfc: Fix possible NULL pointer dereference
@ 2016-07-29 13:30 Johannes Thumshirn
  2016-08-01 15:45 ` Tyrel Datwyler
  2016-08-02  5:17 ` Martin K. Petersen
  0 siblings, 2 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2016-07-29 13:30 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Linux SCSI Mailinglist, Tyrel Datwyler, James Smart,
	Johannes Thumshirn

Check for the existence of piocb->vport before accessing it.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
Changes to v1:
* Fix spelling of piocb (Tyrel)
* re-introduce the BU() assertion if piocb->vport is NULL (Tyrel)


 drivers/scsi/lpfc/lpfc_sli.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 70edf21..3d04ef1 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1323,21 +1323,18 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 {
 	lockdep_assert_held(&phba->hbalock);
 
+	BUG_ON(!piocb || !piocb->vport);
+
 	list_add_tail(&piocb->list, &pring->txcmplq);
 	piocb->iocb_flag |= LPFC_IO_ON_TXCMPLQ;
 
 	if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
 	   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
 	   (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
-	 (!(piocb->vport->load_flag & FC_UNLOADING))) {
-		if (!piocb->vport)
-			BUG();
-		else
-			mod_timer(&piocb->vport->els_tmofunc,
-				jiffies +
-				msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
-	}
-
+	    (!(piocb->vport->load_flag & FC_UNLOADING)))
+		mod_timer(&piocb->vport->els_tmofunc,
+			  jiffies +
+			  msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
 
 	return 0;
 }
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-09  9:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-29 13:30 [PATCH v2] lpfc: Fix possible NULL pointer dereference Johannes Thumshirn
2016-08-01 15:45 ` Tyrel Datwyler
2016-08-02  5:17 ` Martin K. Petersen
2016-12-08 19:01   ` James Bottomley
2016-12-09  9:45     ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).