linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lpfc: Fix possible NULL pointer dereference
@ 2016-06-15 13:00 Johannes Thumshirn
  2016-06-28 20:28 ` Tyrel Datwyler
  2016-07-28 14:58 ` James Smart
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-06-15 13:00 UTC (permalink / raw)
  To: Martin K . Petersen, James Bottomley
  Cc: James Smart, Dick Kennedy, Linux SCSI Mailinglist,
	Linux Kernel Mailinglist, Johannes Thumshirn

Check for the existance of pciob->vport before accessing it.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/lpfc/lpfc_sli.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 70edf21..134078f 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1329,15 +1329,10 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 	if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
 	   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
 	   (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
-	 (!(piocb->vport->load_flag & FC_UNLOADING))) {
-		if (!piocb->vport)
-			BUG();
-		else
-			mod_timer(&piocb->vport->els_tmofunc,
-				jiffies +
-				msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
-	}
-
+	    piocb->vport && !(piocb->vport->load_flag & FC_UNLOADING))
+		mod_timer(&piocb->vport->els_tmofunc,
+			  jiffies +
+			  msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
 
 	return 0;
 }
-- 
1.8.5.6

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

* Re: [PATCH] lpfc: Fix possible NULL pointer dereference
  2016-06-15 13:00 [PATCH] lpfc: Fix possible NULL pointer dereference Johannes Thumshirn
@ 2016-06-28 20:28 ` Tyrel Datwyler
  2016-07-05 12:38   ` Johannes Thumshirn
  2016-07-28 14:58 ` James Smart
  1 sibling, 1 reply; 6+ messages in thread
From: Tyrel Datwyler @ 2016-06-28 20:28 UTC (permalink / raw)
  To: Johannes Thumshirn, Martin K . Petersen, James Bottomley
  Cc: James Smart, Dick Kennedy, Linux SCSI Mailinglist,
	Linux Kernel Mailinglist

On 06/15/2016 06:00 AM, Johannes Thumshirn wrote:
> Check for the existance of pciob->vport before accessing it.

piocb mispelled.

> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/scsi/lpfc/lpfc_sli.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 70edf21..134078f 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -1329,15 +1329,10 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
>  	if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
>  	   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
>  	   (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
> -	 (!(piocb->vport->load_flag & FC_UNLOADING))) {
> -		if (!piocb->vport)
> -			BUG();

Granted the previous code would crash and burn in the if statement prior
to the BUG() assertion if piocb->vport was NULL, but is the condition
!piocb->vport still a bug here? Should that case still be asserted?

-Tyrel

> -		else
> -			mod_timer(&piocb->vport->els_tmofunc,
> -				jiffies +
> -				msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
> -	}
> -
> +	    piocb->vport && !(piocb->vport->load_flag & FC_UNLOADING))
> +		mod_timer(&piocb->vport->els_tmofunc,
> +			  jiffies +
> +			  msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH] lpfc: Fix possible NULL pointer dereference
  2016-06-28 20:28 ` Tyrel Datwyler
@ 2016-07-05 12:38   ` Johannes Thumshirn
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-07-05 12:38 UTC (permalink / raw)
  To: Tyrel Datwyler
  Cc: Martin K . Petersen, James Bottomley, James Smart, Dick Kennedy,
	Linux SCSI Mailinglist, Linux Kernel Mailinglist

On Tue, Jun 28, 2016 at 01:28:19PM -0700, Tyrel Datwyler wrote:
> On 06/15/2016 06:00 AM, Johannes Thumshirn wrote:
> > Check for the existance of pciob->vport before accessing it.
> 
> piocb mispelled.

Oops

> 
> > 
> > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> > ---
> >  drivers/scsi/lpfc/lpfc_sli.c | 13 ++++---------
> >  1 file changed, 4 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> > index 70edf21..134078f 100644
> > --- a/drivers/scsi/lpfc/lpfc_sli.c
> > +++ b/drivers/scsi/lpfc/lpfc_sli.c
> > @@ -1329,15 +1329,10 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
> >  	if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
> >  	   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
> >  	   (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
> > -	 (!(piocb->vport->load_flag & FC_UNLOADING))) {
> > -		if (!piocb->vport)
> > -			BUG();
> 
> Granted the previous code would crash and burn in the if statement prior
> to the BUG() assertion if piocb->vport was NULL, but is the condition
> !piocb->vport still a bug here? Should that case still be asserted?

Yes, you're right. Let me see how to solve it _and_ make the statement a bit
more readable.

Thanks,
	Johannes

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* Re: [PATCH] lpfc: Fix possible NULL pointer dereference
  2016-06-15 13:00 [PATCH] lpfc: Fix possible NULL pointer dereference Johannes Thumshirn
  2016-06-28 20:28 ` Tyrel Datwyler
@ 2016-07-28 14:58 ` James Smart
  2016-07-29  1:21   ` Martin K. Petersen
  1 sibling, 1 reply; 6+ messages in thread
From: James Smart @ 2016-07-28 14:58 UTC (permalink / raw)
  To: Johannes Thumshirn, Martin K . Petersen, James Bottomley
  Cc: James Smart, Dick Kennedy, Linux SCSI Mailinglist,
	Linux Kernel Mailinglist

This patch is good. Thanks

-- james

Signed-off-by: James Smart  <james.smart@broadcom.com>


On 6/15/2016 6:00 AM, Johannes Thumshirn wrote:
> Check for the existance of pciob->vport before accessing it.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>   drivers/scsi/lpfc/lpfc_sli.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 70edf21..134078f 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -1329,15 +1329,10 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
>   	if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
>   	   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
>   	   (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
> -	 (!(piocb->vport->load_flag & FC_UNLOADING))) {
> -		if (!piocb->vport)
> -			BUG();
> -		else
> -			mod_timer(&piocb->vport->els_tmofunc,
> -				jiffies +
> -				msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
> -	}
> -
> +	    piocb->vport && !(piocb->vport->load_flag & FC_UNLOADING))
> +		mod_timer(&piocb->vport->els_tmofunc,
> +			  jiffies +
> +			  msecs_to_jiffies(1000 * (phba->fc_ratov << 1)));
>   
>   	return 0;
>   }

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

* Re: [PATCH] lpfc: Fix possible NULL pointer dereference
  2016-07-28 14:58 ` James Smart
@ 2016-07-29  1:21   ` Martin K. Petersen
  2016-07-29  8:06     ` Johannes Thumshirn
  0 siblings, 1 reply; 6+ messages in thread
From: Martin K. Petersen @ 2016-07-29  1:21 UTC (permalink / raw)
  To: James Smart
  Cc: Johannes Thumshirn, Martin K . Petersen, James Bottomley,
	James Smart, Dick Kennedy, Linux SCSI Mailinglist,
	Linux Kernel Mailinglist

>>>>> "James" == James Smart <james.smart@broadcom.com> writes:

James> This patch is good.

Johannes: You were going to tweak a few things and resubmit. Please do.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] lpfc: Fix possible NULL pointer dereference
  2016-07-29  1:21   ` Martin K. Petersen
@ 2016-07-29  8:06     ` Johannes Thumshirn
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2016-07-29  8:06 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: James Smart, James Bottomley, James Smart, Dick Kennedy,
	Linux SCSI Mailinglist, Linux Kernel Mailinglist

On Thu, Jul 28, 2016 at 09:21:47PM -0400, Martin K . Petersen wrote:
> >>>>> "James" == James Smart <james.smart@broadcom.com> writes:
> 
> James> This patch is good.
> 
> Johannes: You were going to tweak a few things and resubmit. Please do.

Oh yes, sorry totally forgot about this one.

My bad.

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

end of thread, other threads:[~2016-07-29  8:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 13:00 [PATCH] lpfc: Fix possible NULL pointer dereference Johannes Thumshirn
2016-06-28 20:28 ` Tyrel Datwyler
2016-07-05 12:38   ` Johannes Thumshirn
2016-07-28 14:58 ` James Smart
2016-07-29  1:21   ` Martin K. Petersen
2016-07-29  8:06     ` Johannes Thumshirn

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).