lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231011130350.819571-1-haowenchao2@huawei.com>
Date: Wed, 11 Oct 2023 21:03:50 +0800
From: Wenchao Hao <haowenchao2@...wei.com>
To: Hannes Reinecke <hare@...e.de>, "James E . J . Bottomley"
	<jejb@...ux.ibm.com>, "Martin K . Petersen" <martin.petersen@...cle.com>,
	Richard Cochran <richardcochran@...il.com>, <linux-scsi@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
	<louhongxiang@...wei.com>, Wenchao Hao <haowenchao2@...wei.com>
Subject: [PATCH] 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 is possible to return NULL which 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@...wei.com>
---
 drivers/scsi/libfc/fc_lport.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 9c02c9523c4d..904d66160785 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -241,6 +241,12 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
 	}
 	mutex_lock(&lport->disc.disc_mutex);
 	lport->ptp_rdata = fc_rport_create(lport, remote_fid);
+	if (!lport->ptp_rdata) {
+		printk(KERN_WARNING "libfc: Failed to setup lport 0x%x\n",
+			lport->port_id);
+		mutex_unlock(&lport->disc.disc_mutex);
+		return;
+	}
 	kref_get(&lport->ptp_rdata->kref);
 	lport->ptp_rdata->ids.port_name = remote_wwpn;
 	lport->ptp_rdata->ids.node_name = remote_wwnn;
-- 
2.32.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ