public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: usb: dwc3: ep0: return early on NULL requests
       [not found] <20141101222047.7178B6610BF@gitolite.kernel.org>
@ 2014-11-10 20:32 ` Dave Jones
  2014-11-10 20:37   ` Felipe Balbi
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jones @ 2014-11-10 20:32 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: balbi

On Sat, Nov 01, 2014 at 10:20:47PM +0000, Linux Kernel wrote:
 > Gitweb:     http://git.kernel.org/linus/;a=commit;h=6856d30c6c0038dc0648009853533af3af6c5ba8
 > Commit:     6856d30c6c0038dc0648009853533af3af6c5ba8
 > Parent:     7d643664ea559b36188cae264047ce3c9bfec3a2
 > Refname:    refs/heads/master
 > Author:     Felipe Balbi <balbi@ti.com>
 > AuthorDate: Tue Sep 30 11:43:20 2014 -0500
 > Committer:  Felipe Balbi <balbi@ti.com>
 > CommitDate: Mon Oct 20 15:58:49 2014 -0500
 > 
 >     usb: dwc3: ep0: return early on NULL requests
 >     
 >     if our list of requests is empty, return early.

....

 > diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
 > index ae6b575..a47cc1e 100644
 > --- a/drivers/usb/dwc3/ep0.c
 > +++ b/drivers/usb/dwc3/ep0.c
 > @@ -789,9 +789,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
 >  
 >  	dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
 >  
 > -	r = next_request(&ep0->request_list);
 > -	ur = &r->request;
 > -
 >  	trb = dwc->ep0_trb;

 
Since the deletion of this assignment to 'r', we're now doing
a comparison on it, resulting in dead code that will never be
reached..

** CID 1251381:  Logically dead code  (DEADCODE)
/drivers/usb/dwc3/ep0.c: 799 in dwc3_ep0_complete_data()


________________________________________________________________________________________________________
*** CID 1251381:  Logically dead code  (DEADCODE)
/drivers/usb/dwc3/ep0.c: 799 in dwc3_ep0_complete_data()
793
794             status = DWC3_TRB_SIZE_TRBSTS(trb->size);
795             if (status == DWC3_TRBSTS_SETUP_PENDING) {
796                     dwc3_trace(trace_dwc3_ep0, "Setup Pending received");
797
798                     if (r)
>>>     CID 1251381:  Logically dead code  (DEADCODE)
>>>     Execution cannot reach this statement: "dwc3_gadget_giveback(ep0, r...".
799                             dwc3_gadget_giveback(ep0, r, -ECONNRESET);
800
801                     return;
802             }
803
804             r = next_request(&ep0->request_list);

Picked up by Coverity scan.

	Dave


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

* Re: usb: dwc3: ep0: return early on NULL requests
  2014-11-10 20:32 ` usb: dwc3: ep0: return early on NULL requests Dave Jones
@ 2014-11-10 20:37   ` Felipe Balbi
  0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2014-11-10 20:37 UTC (permalink / raw)
  To: Dave Jones, Linux Kernel Mailing List, balbi

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

On Mon, Nov 10, 2014 at 03:32:29PM -0500, Dave Jones wrote:
> On Sat, Nov 01, 2014 at 10:20:47PM +0000, Linux Kernel wrote:
>  > Gitweb:     http://git.kernel.org/linus/;a=commit;h=6856d30c6c0038dc0648009853533af3af6c5ba8
>  > Commit:     6856d30c6c0038dc0648009853533af3af6c5ba8
>  > Parent:     7d643664ea559b36188cae264047ce3c9bfec3a2
>  > Refname:    refs/heads/master
>  > Author:     Felipe Balbi <balbi@ti.com>
>  > AuthorDate: Tue Sep 30 11:43:20 2014 -0500
>  > Committer:  Felipe Balbi <balbi@ti.com>
>  > CommitDate: Mon Oct 20 15:58:49 2014 -0500
>  > 
>  >     usb: dwc3: ep0: return early on NULL requests
>  >     
>  >     if our list of requests is empty, return early.
> 
> ....
> 
>  > diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
>  > index ae6b575..a47cc1e 100644
>  > --- a/drivers/usb/dwc3/ep0.c
>  > +++ b/drivers/usb/dwc3/ep0.c
>  > @@ -789,9 +789,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
>  >  
>  >  	dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
>  >  
>  > -	r = next_request(&ep0->request_list);
>  > -	ur = &r->request;
>  > -
>  >  	trb = dwc->ep0_trb;
> 
>  
> Since the deletion of this assignment to 'r', we're now doing
> a comparison on it, resulting in dead code that will never be
> reached..

very true, here's a patch to fix it up again :-) i'll send it properly
in a bit.

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 711b230..df38e7e 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -791,6 +791,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
 
 	trb = dwc->ep0_trb;
 
+	r = next_request(&ep0->request_list);
+	if (!r)
+		return;
+
 	status = DWC3_TRB_SIZE_TRBSTS(trb->size);
 	if (status == DWC3_TRBSTS_SETUP_PENDING) {
 		dwc3_trace(trace_dwc3_ep0, "Setup Pending received");
@@ -801,10 +805,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
 		return;
 	}
 
-	r = next_request(&ep0->request_list);
-	if (!r)
-		return;
-
 	ur = &r->request;
 
 	length = trb->size & DWC3_TRB_SIZE_MASK;

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2014-11-10 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20141101222047.7178B6610BF@gitolite.kernel.org>
2014-11-10 20:32 ` usb: dwc3: ep0: return early on NULL requests Dave Jones
2014-11-10 20:37   ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox