summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Smart2016-03-31 23:12:29 +0200
committerMartin K. Petersen2016-04-11 22:57:09 +0200
commita6517db9006eb618dfde54f4bf6a9a8bc21e16e7 (patch)
treed50ed2d0cc6d34b76f012d9187125d6f80e5d439
parentlpfc: Fix DMA faults observed upon plugging loopback connector (diff)
downloadkernel-qcow2-linux-a6517db9006eb618dfde54f4bf6a9a8bc21e16e7.tar.gz
kernel-qcow2-linux-a6517db9006eb618dfde54f4bf6a9a8bc21e16e7.tar.xz
kernel-qcow2-linux-a6517db9006eb618dfde54f4bf6a9a8bc21e16e7.zip
lpfc: Fix crash when unregistering default rpi.
The default rpi completion handler does back to back puts to force the removal of the ndlp. This ends up calling lpfc_unreg_rpi after the reference count is at 0. Fix: Check the reference count of the ndlp before getting the ref to make sure we are not getting a reference on a removed object. Signed-off-by: Dick Kennedy <dick.kennedy@avagotech.com> Signed-off-by: James Smart <james.smart@avagotech.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 25b5dcd1a5c8..b3bf230f714a 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -4545,7 +4545,8 @@ lpfc_unreg_rpi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
(!(vport->load_flag & FC_UNLOADING)) &&
(bf_get(lpfc_sli_intf_if_type,
&phba->sli4_hba.sli_intf) ==
- LPFC_SLI_INTF_IF_TYPE_2)) {
+ LPFC_SLI_INTF_IF_TYPE_2) &&
+ (atomic_read(&ndlp->kref.refcount) > 0)) {
mbox->context1 = lpfc_nlp_get(ndlp);
mbox->mbox_cmpl =
lpfc_sli4_unreg_rpi_cmpl_clr;