Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: libfc: fix null pointer dereference on a null lport

Currently if lport is null then the null lport pointer is dereference when
printing out debug via the FC_LPORT_DB macro. Fix this by using the more
generic FC_LIBFC_DBG debug macro instead that does not use lport.

Addresses-Coverity: ("Dereference after null check")
Fixes: 7414705ea4ae ("libfc: Add runtime debugging with debug_logging module parameter")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Colin Ian King and committed by
Martin K. Petersen
41a6bf65 48464708

+1 -1
+1 -1
drivers/scsi/libfc/fc_exch.c
··· 2591 2591 2592 2592 /* lport lock ? */ 2593 2593 if (!lport || lport->state == LPORT_ST_DISABLED) { 2594 - FC_LPORT_DBG(lport, "Receiving frames for an lport that " 2594 + FC_LIBFC_DBG("Receiving frames for an lport that " 2595 2595 "has not been initialized correctly\n"); 2596 2596 fc_frame_free(fp); 2597 2597 return;