LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] scsi: libfc: fix null pointer dereference on a null lport
@ 2019-07-02  9:18 Colin King
  2019-07-12  1:47 ` Martin K. Petersen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Colin King @ 2019-07-02  9:18 UTC (permalink / raw)
  To: Hannes Reinecke, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently if lport is null then the null lport pointer is dereference
when printing out debug via the FC_LPORT_DB macro. Fix this by using
the more generic FC_LIBFC_DBG debug macro instead that does not use
lport.

Addresses-Coverity: ("Dereference after null check")
Fixes: 7414705ea4ae ("libfc: Add runtime debugging with debug_logging module parameter")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/libfc/fc_exch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 025cd2ff9f65..c477fadbf504 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -2591,8 +2591,8 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
 
 	/* lport lock ? */
 	if (!lport || lport->state == LPORT_ST_DISABLED) {
-		FC_LPORT_DBG(lport, "Receiving frames for an lport that "
-			     "has not been initialized correctly\n");
+		FC_LIBFC_DBG("Receiving frames for an lport that "
+			     "has not been initialized correctly\n");
 		fc_frame_free(fp);
 		return;
 	}
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: libfc: fix null pointer dereference on a null lport
  2019-07-02  9:18 [PATCH] scsi: libfc: fix null pointer dereference on a null lport Colin King
@ 2019-07-12  1:47 ` Martin K. Petersen
  2019-07-12  6:34 ` Hannes Reinecke
  2019-07-17  2:32 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2019-07-12  1:47 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Colin King, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, kernel-janitors, linux-kernel


Hannes,

Please review!

> Currently if lport is null then the null lport pointer is dereference
> when printing out debug via the FC_LPORT_DB macro. Fix this by using
> the more generic FC_LIBFC_DBG debug macro instead that does not use
> lport.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: libfc: fix null pointer dereference on a null lport
  2019-07-02  9:18 [PATCH] scsi: libfc: fix null pointer dereference on a null lport Colin King
  2019-07-12  1:47 ` Martin K. Petersen
@ 2019-07-12  6:34 ` Hannes Reinecke
  2019-07-12 10:43   ` Julia Lawall
  2019-07-17  2:32 ` Martin K. Petersen
  2 siblings, 1 reply; 5+ messages in thread
From: Hannes Reinecke @ 2019-07-12  6:34 UTC (permalink / raw)
  To: Colin King, James E . J . Bottomley, Martin K . Petersen, linux-scsi
  Cc: kernel-janitors, linux-kernel

On 7/2/19 11:18 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently if lport is null then the null lport pointer is dereference
> when printing out debug via the FC_LPORT_DB macro. Fix this by using
> the more generic FC_LIBFC_DBG debug macro instead that does not use
> lport.
> 
> Addresses-Coverity: ("Dereference after null check")
> Fixes: 7414705ea4ae ("libfc: Add runtime debugging with debug_logging module parameter")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/scsi/libfc/fc_exch.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
> index 025cd2ff9f65..c477fadbf504 100644
> --- a/drivers/scsi/libfc/fc_exch.c
> +++ b/drivers/scsi/libfc/fc_exch.c
> @@ -2591,8 +2591,8 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
>  
>  	/* lport lock ? */
>  	if (!lport || lport->state == LPORT_ST_DISABLED) {
> -		FC_LPORT_DBG(lport, "Receiving frames for an lport that "
> -			     "has not been initialized correctly\n");
> +		FC_LIBFC_DBG("Receiving frames for an lport that "
> +			     "has not been initialized correctly\n");
>  		fc_frame_free(fp);
>  		return;
>  	}
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: libfc: fix null pointer dereference on a null lport
  2019-07-12  6:34 ` Hannes Reinecke
@ 2019-07-12 10:43   ` Julia Lawall
  0 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-07-12 10:43 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Colin King, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]



On Fri, 12 Jul 2019, Hannes Reinecke wrote:

> On 7/2/19 11:18 AM, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently if lport is null then the null lport pointer is dereference
> > when printing out debug via the FC_LPORT_DB macro. Fix this by using
> > the more generic FC_LIBFC_DBG debug macro instead that does not use
> > lport.
> >
> > Addresses-Coverity: ("Dereference after null check")
> > Fixes: 7414705ea4ae ("libfc: Add runtime debugging with debug_logging module parameter")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/scsi/libfc/fc_exch.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
> > index 025cd2ff9f65..c477fadbf504 100644
> > --- a/drivers/scsi/libfc/fc_exch.c
> > +++ b/drivers/scsi/libfc/fc_exch.c
> > @@ -2591,8 +2591,8 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
> >
> >  	/* lport lock ? */
> >  	if (!lport || lport->state == LPORT_ST_DISABLED) {
> > -		FC_LPORT_DBG(lport, "Receiving frames for an lport that "
> > -			     "has not been initialized correctly\n");
> > +		FC_LIBFC_DBG("Receiving frames for an lport that "
> > +			     "has not been initialized correctly\n");

If the code is being changed, perhaps the string could be put onto one
line as well.

julia

> >  		fc_frame_free(fp);
> >  		return;
> >  	}
> >
> Reviewed-by: Hannes Reinecke <hare@suse.com>
>
> Cheers,
>
> Hannes
> --
> Dr. Hannes Reinecke		   Teamlead Storage & Networking
> hare@suse.de			               +49 911 74053 688
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
> HRB 21284 (AG Nürnberg)
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: libfc: fix null pointer dereference on a null lport
  2019-07-02  9:18 [PATCH] scsi: libfc: fix null pointer dereference on a null lport Colin King
  2019-07-12  1:47 ` Martin K. Petersen
  2019-07-12  6:34 ` Hannes Reinecke
@ 2019-07-17  2:32 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2019-07-17  2:32 UTC (permalink / raw)
  To: Colin King
  Cc: Hannes Reinecke, James E . J . Bottomley, Martin K . Petersen,
	linux-scsi, kernel-janitors, linux-kernel


Colin,

> Currently if lport is null then the null lport pointer is dereference
> when printing out debug via the FC_LPORT_DB macro. Fix this by using
> the more generic FC_LIBFC_DBG debug macro instead that does not use
> lport.

Applied to 5.3/scsi-fixes, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-17  2:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02  9:18 [PATCH] scsi: libfc: fix null pointer dereference on a null lport Colin King
2019-07-12  1:47 ` Martin K. Petersen
2019-07-12  6:34 ` Hannes Reinecke
2019-07-12 10:43   ` Julia Lawall
2019-07-17  2:32 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).