Patch "scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-libfc-fix-potential-null-pointer-dereference-in.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 42a5bfd733e7f80dfef2c208dd4b5f547633cce0
Author: Wenchao Hao <haowenchao2@xxxxxxxxxx>
Date:   Wed Oct 11 21:03:50 2023 +0800

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

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index abb14b206be04..82b8477c7d737 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -238,6 +238,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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux