Skip to content

Commit 4df105f

Browse files
wenchao-haomartinkpetersen
authored andcommitted
scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup()
fc_lport_ptp_setup() did not check the return value of fc_rport_create() which can return NULL and would cause a NULL pointer dereference. Address this issue by checking return value of fc_rport_create() and log error message on fc_rport_create() failed. Signed-off-by: Wenchao Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f42706a commit 4df105f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/scsi/libfc/fc_lport.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
241241
}
242242
mutex_lock(&lport->disc.disc_mutex);
243243
lport->ptp_rdata = fc_rport_create(lport, remote_fid);
244+
if (!lport->ptp_rdata) {
245+
printk(KERN_WARNING "libfc: Failed to setup lport 0x%x\n",
246+
lport->port_id);
247+
mutex_unlock(&lport->disc.disc_mutex);
248+
return;
249+
}
244250
kref_get(&lport->ptp_rdata->kref);
245251
lport->ptp_rdata->ids.port_name = remote_wwpn;
246252
lport->ptp_rdata->ids.node_name = remote_wwnn;

0 commit comments

Comments
 (0)