scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup()
authorWenchao Hao <haowenchao2@huawei.com>
Wed, 11 Oct 2023 13:03:50 +0000 (21:03 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:07:00 +0000 (17:07 +0000)
commit442fd24d7b6b29e4a9cd9225afba4142d5f522ba
tree3359a375e724923f58fce0cff3d3c972878007d9
parentdabc0ee84d0d6e4a382ae6ee7893cb784f880dce
scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup()

[ Upstream commit 4df105f0ce9f6f30cda4e99f577150d23f0c9c5f ]

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 <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20231011130350.819571-1-haowenchao2@huawei.com
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/libfc/fc_lport.c