Skip to content

Commit 2e4b02f

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()
The kref_put() function will call nport->release if the refcount drops to zero. The nport->release release function is _efc_nport_free() which frees "nport". But then we dereference "nport" on the next line which is a use after free. Re-order these lines to avoid the use after free. Fixes: fcd4273 ("scsi: elx: libefc: SLI and FC PORT state machine interfaces") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 89835a5 commit 2e4b02f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/elx/libefc/efc_nport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,9 @@ efc_nport_vport_del(struct efc *efc, struct efc_domain *domain,
705705
spin_lock_irqsave(&efc->lock, flags);
706706
list_for_each_entry(nport, &domain->nport_list, list_entry) {
707707
if (nport->wwpn == wwpn && nport->wwnn == wwnn) {
708-
kref_put(&nport->ref, nport->release);
709708
/* Shutdown this NPORT */
710709
efc_sm_post_event(&nport->sm, EFC_EVT_SHUTDOWN, NULL);
710+
kref_put(&nport->ref, nport->release);
711711
break;
712712
}
713713
}

0 commit comments

Comments
 (0)