[PATCH] scsi:libfc:fix fc_lport_ptp_setup(): Null pointer dereferences

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

 



From: Wu Bo <wubo40@xxxxxxxxxx>

The code following:
fc_rport_create()
    ...
    rdata = kzalloc(sizeof(*rdata) + lport->rport_priv_size, GFP_KERNEL);
    if (!rdata)
        return NULL;
    ...

fc_lport_ptp_setup()
   ...
   lport->ptp_rdata = fc_rport_create(lport, remote_fid);
   kref_get(&lport->ptp_rdata->kref);
   lport->ptp_rdata->ids.port_name = remote_wwpn;
   ...

Fix by adding a check for lport->ptp_rdata before be used on fc_lport_ptp_setup func.

Signed-off-by: Wu Bo <wubo40@xxxxxxxxxx>
---
 drivers/scsi/libfc/fc_lport.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 684c5e3..36e7bdd 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -238,6 +238,10 @@ 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) {
+               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;
--
1.8.3.1



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux