scsi: libfc: Fix potential NULL pointer dereference
Subsystems (2)
PATCH 1/1 scsi: libfc: Fix potential NULL pointer dereference
There is a potential NULL pointer dereference in case fc_rport_create() fails and returns NULL.
--- drivers/scsi/libfc/fc_lport.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/libfc/fc_lport.c +4 -0
@@ -250,6 +250,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;
Signature · 1 line
2.7.0
Friendly ping:
Who can review or take this, please?
Thanks
Quoted 25 lines · YueHaibing
There is a potential NULL pointer dereference in case
fc_rport_create()fails and returns NULL.Fixes 2580064b5ec6 ("scsi: libfc: Replace ->rport_create callback with function call")Signed-off-by YueHaibing <[email protected]>--- drivers/scsi/libfc/fc_lport.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/scsi/libfc/fc_lport.c +4
-0@@ -250,6 +250,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;
Hannes Reinecke
maintainerQuoted 17 lines · YueHaibing
Friendly ping:
Who can review or take this, please?
Thanks
Quoted 9 lines · YueHaibing
There is a potential NULL pointer dereference in case
fc_rport_create()fails and returns NULL.Fixes 2580064b5ec6 ("scsi: libfc: Replace ->rport_create callback with function call")Signed-off-by YueHaibing <[email protected]>--- drivers/scsi/libfc/fc_lport.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 17 lines
Quoted 6 lines
drivers/scsi/libfc/fc_lport.c +0
-0drivers/scsi/libfc/fc_lport.c static void fc_lport_ptp_setup(struct fc_lport *lport, · line 259
Quoted 10 lines
drivers/scsi/libfc/fc_lport.c +4
-0@@ -250,6 +250,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;
I don't think this is correct.
While it's true that fc_rport_create() might fail, fc_lport_ptp_setup() will still assumed to have worked by the caller. So we should rather return an error code here from fc_lport_ptp_setup() and ensure it's handled properly in the caller, too.
Cheers,
Hannes
Quoted 17 lines · YueHaibing
Friendly ping:
Who can review or take this, please?
Thanks
Quoted 9 lines · YueHaibing
There is a potential NULL pointer dereference in case
fc_rport_create()fails and returns NULL.Fixes 2580064b5ec6 ("scsi: libfc: Replace ->rport_create callback with function call")Signed-off-by YueHaibing <[email protected]>--- drivers/scsi/libfc/fc_lport.c | 4 ++++ 1 file changed, 4 insertions(+)
Quoted 17 lines
Quoted 6 lines
drivers/scsi/libfc/fc_lport.c +0
-0drivers/scsi/libfc/fc_lport.c static void fc_lport_ptp_setup(struct fc_lport *lport, · line 259
Quoted 10 lines
drivers/scsi/libfc/fc_lport.c +4
-0@@ -250,6 +250,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;
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Hi Hannes,
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
There is a potential NULL pointer dereference in case
fc_rport_create()fails and returns NULL.drivers/scsi/libfc/fc_lport.c +2
-0@@ -250,6 +250,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);
Quoted 8 lines
Quoted 6 lines
drivers/scsi/libfc/fc_lport.c static void fc_lport_ptp_setup(struct fc_lport *lport, · line 259
Quoted 6 lines
drivers/scsi/libfc/fc_lport.c +2
-0+return ; + }kref_get (&lport->ptp_rdata->kref); lport->ptp_rdata->ids.port_name = remote_wwpn; lport->ptp_rdata->ids.node_name = remote_wwnn;Reviewed-by Hannes Reinecke <[email protected]>
A bit confused. You had originally replied that the patch was not correct so I closed it in patchwork. And now there's a Reviewed-by:
without any explanation as to why you have changed your mind.
Please clarify, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering