[15/42] lpfc: Fix null ptr oops updating lpfc_devloss_tmo via sysfs attribute
diff mbox series

Message ID 20190814235712.4487-16-jsmart2021@gmail.com
State Accepted
Headers show
Series
  • lpfc: Update lpfc to revision 12.4.0.0
Related show

Commit Message

James Smart Aug. 14, 2019, 11:56 p.m. UTC
If an admin updates lpfc's devloss_tmo sysfs attribute, the kernel
will oops.

Coding of a loop allowed a new value (rport) to be set/checked for null
followed by an older value (remoteport) checked for null to allow
progress where the new value, even though null, will be referenced.

Rework the logic to validate and prevent any reference to the null ptr.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
---
 drivers/scsi/lpfc/lpfc_attr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 8d8c495b5b60..33c8bae49821 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3682,8 +3682,8 @@  lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport)
 		if (rport)
 			remoteport = rport->remoteport;
 		spin_unlock(&vport->phba->hbalock);
-		if (remoteport)
-			nvme_fc_set_remoteport_devloss(rport->remoteport,
+		if (rport && remoteport)
+			nvme_fc_set_remoteport_devloss(remoteport,
 						       vport->cfg_devloss_tmo);
 #endif
 	}