* [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance
@ 2014-10-17 4:44 Sudip Mukherjee
2014-10-17 4:44 ` [PATCH v3 2/2] usb: dwc2: gadget: modify return statement Sudip Mukherjee
2014-10-17 18:50 ` [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Paul Zimmerman
0 siblings, 2 replies; 12+ messages in thread
From: Sudip Mukherjee @ 2014-10-17 4:44 UTC (permalink / raw)
To: Paul Zimmerman, Greg Kroah-Hartman
Cc: Sudip Mukherjee, linux-usb, linux-kernel
sparse was giving the following warning:
warning: context imbalance in 's3c_hsotg_ep_enable'
- different lock contexts for basic block
we were returning ENOMEM while still holding the spinlock.
The sparse warning was fixed by releasing the spinlock before return.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/usb/dwc2/gadget.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b5856f..7f25527 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
hs_ep->fifo_size = val;
break;
}
- if (i == 8)
- return -ENOMEM;
+ if (i == 8) {
+ ret = -ENOMEM;
+ goto error;
+ }
}
/* for non control endpoints, set PID to D0 */
@@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
/* enable the endpoint interrupt */
s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1);
+error:
spin_unlock_irqrestore(&hsotg->lock, flags);
return ret;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH v3 2/2] usb: dwc2: gadget: modify return statement 2014-10-17 4:44 [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Sudip Mukherjee @ 2014-10-17 4:44 ` Sudip Mukherjee 2014-10-17 9:02 ` David Laight 2014-10-17 18:52 ` Paul Zimmerman 2014-10-17 18:50 ` [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Paul Zimmerman 1 sibling, 2 replies; 12+ messages in thread From: Sudip Mukherjee @ 2014-10-17 4:44 UTC (permalink / raw) To: Paul Zimmerman, Greg Kroah-Hartman Cc: Sudip Mukherjee, linux-usb, linux-kernel modified the function to have a single return statement at the end instead of multiple return statement in the middle of the function to improve the readability of the code. This patch depends on the previous patch of the series. Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> --- drivers/usb/dwc2/gadget.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 7f25527..e8a8fc7 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2471,7 +2471,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; if (dir_in != hs_ep->dir_in) { dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto error1; } mps = usb_endpoint_maxp(desc); @@ -2583,6 +2584,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, error: spin_unlock_irqrestore(&hsotg->lock, flags); +error1: return ret; } -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] usb: dwc2: gadget: modify return statement 2014-10-17 4:44 ` [PATCH v3 2/2] usb: dwc2: gadget: modify return statement Sudip Mukherjee @ 2014-10-17 9:02 ` David Laight 2014-10-17 10:03 ` Sudip Mukherjee 2014-10-17 18:52 ` Paul Zimmerman 1 sibling, 1 reply; 12+ messages in thread From: David Laight @ 2014-10-17 9:02 UTC (permalink / raw) To: 'Sudip Mukherjee', Paul Zimmerman, Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org From: Of Sudip Mukherjee > modified the function to have a single return statement at the end > instead of multiple return statement in the middle of the function > to improve the readability of the code. Many of us would disagree with you there. Early returns actually make the code easier to read, certainly better than a goto 'end of function'. David > This patch depends on the previous patch of the series. > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > --- > drivers/usb/dwc2/gadget.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > index 7f25527..e8a8fc7 100644 > --- a/drivers/usb/dwc2/gadget.c > +++ b/drivers/usb/dwc2/gadget.c > @@ -2471,7 +2471,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; > if (dir_in != hs_ep->dir_in) { > dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); > - return -EINVAL; > + ret = -EINVAL; > + goto error1; > } > > mps = usb_endpoint_maxp(desc); > @@ -2583,6 +2584,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > error: > spin_unlock_irqrestore(&hsotg->lock, flags); > +error1: > return ret; > } > > -- > 1.8.1.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 2/2] usb: dwc2: gadget: modify return statement 2014-10-17 9:02 ` David Laight @ 2014-10-17 10:03 ` Sudip Mukherjee 2014-10-17 18:10 ` Paul Zimmerman 0 siblings, 1 reply; 12+ messages in thread From: Sudip Mukherjee @ 2014-10-17 10:03 UTC (permalink / raw) To: David Laight Cc: Paul Zimmerman, Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org On Fri, Oct 17, 2014 at 09:02:00AM +0000, David Laight wrote: > From: Of Sudip Mukherjee > > modified the function to have a single return statement at the end > > instead of multiple return statement in the middle of the function > > to improve the readability of the code. > > Many of us would disagree with you there. > Early returns actually make the code easier to read, certainly > better than a goto 'end of function'. > actually , frankly speaking, this first return statement was also easier for me to understand. But in my v1 patch , Paul mentioned : >For a long function like this, I'd rather keep a single return point at >the end. so I thought he meant all the return statements in the function. thanks sudip > David > > > This patch depends on the previous patch of the series. > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > --- > > drivers/usb/dwc2/gadget.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > index 7f25527..e8a8fc7 100644 > > --- a/drivers/usb/dwc2/gadget.c > > +++ b/drivers/usb/dwc2/gadget.c > > @@ -2471,7 +2471,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; > > if (dir_in != hs_ep->dir_in) { > > dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto error1; > > } > > > > mps = usb_endpoint_maxp(desc); > > @@ -2583,6 +2584,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > error: > > spin_unlock_irqrestore(&hsotg->lock, flags); > > +error1: > > return ret; > > } > > > > -- > > 1.8.1.2 > > > > -- > > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] usb: dwc2: gadget: modify return statement 2014-10-17 10:03 ` Sudip Mukherjee @ 2014-10-17 18:10 ` Paul Zimmerman 0 siblings, 0 replies; 12+ messages in thread From: Paul Zimmerman @ 2014-10-17 18:10 UTC (permalink / raw) To: Sudip Mukherjee, David Laight Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > Sent: Friday, October 17, 2014 3:03 AM > > On Fri, Oct 17, 2014 at 09:02:00AM +0000, David Laight wrote: > > From: Of Sudip Mukherjee > > > modified the function to have a single return statement at the end > > > instead of multiple return statement in the middle of the function > > > to improve the readability of the code. > > > > Many of us would disagree with you there. > > Early returns actually make the code easier to read, certainly > > better than a goto 'end of function'. > > > actually , frankly speaking, this first return statement was also easier for me to understand. But in > my v1 patch , Paul mentioned : > >For a long function like this, I'd rather keep a single return point at > >the end. > so I thought he meant all the return statements in the function. What I didn't like about your first patch was that there were two places where the spinlock was released. I think that is error-prone, as can be seen by the original bug. But I am OK with leaving the first return statement as-is, since the spinlock is not held there. So I think we should apply patch 1, and drop patch 2. -- Paul ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 2/2] usb: dwc2: gadget: modify return statement 2014-10-17 4:44 ` [PATCH v3 2/2] usb: dwc2: gadget: modify return statement Sudip Mukherjee 2014-10-17 9:02 ` David Laight @ 2014-10-17 18:52 ` Paul Zimmerman 1 sibling, 0 replies; 12+ messages in thread From: Paul Zimmerman @ 2014-10-17 18:52 UTC (permalink / raw) To: Sudip Mukherjee, balbi@ti.com, Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > Sent: Thursday, October 16, 2014 9:44 PM > > modified the function to have a single return statement at the end > instead of multiple return statement in the middle of the function > to improve the readability of the code. > > This patch depends on the previous patch of the series. > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > --- > drivers/usb/dwc2/gadget.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > index 7f25527..e8a8fc7 100644 > --- a/drivers/usb/dwc2/gadget.c > +++ b/drivers/usb/dwc2/gadget.c > @@ -2471,7 +2471,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; > if (dir_in != hs_ep->dir_in) { > dev_err(hsotg->dev, "%s: direction mismatch!\n", __func__); > - return -EINVAL; > + ret = -EINVAL; > + goto error1; > } > > mps = usb_endpoint_maxp(desc); > @@ -2583,6 +2584,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > error: > spin_unlock_irqrestore(&hsotg->lock, flags); > +error1: > return ret; > } According to the discussion in another thread, let's drop this patch. -- Paul ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-17 4:44 [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Sudip Mukherjee 2014-10-17 4:44 ` [PATCH v3 2/2] usb: dwc2: gadget: modify return statement Sudip Mukherjee @ 2014-10-17 18:50 ` Paul Zimmerman 2014-10-17 18:52 ` Felipe Balbi 1 sibling, 1 reply; 12+ messages in thread From: Paul Zimmerman @ 2014-10-17 18:50 UTC (permalink / raw) To: Sudip Mukherjee, balbi@ti.com, Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > Sent: Thursday, October 16, 2014 9:44 PM > > sparse was giving the following warning: > warning: context imbalance in 's3c_hsotg_ep_enable' > - different lock contexts for basic block > > we were returning ENOMEM while still holding the spinlock. > The sparse warning was fixed by releasing the spinlock before return. > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > --- > drivers/usb/dwc2/gadget.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > index 7b5856f..7f25527 100644 > --- a/drivers/usb/dwc2/gadget.c > +++ b/drivers/usb/dwc2/gadget.c > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > hs_ep->fifo_size = val; > break; > } > - if (i == 8) > - return -ENOMEM; > + if (i == 8) { > + ret = -ENOMEM; > + goto error; > + } > } > > /* for non control endpoints, set PID to D0 */ > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > /* enable the endpoint interrupt */ > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > +error: > spin_unlock_irqrestore(&hsotg->lock, flags); > return ret; > } Acked-by: Paul Zimmerman <paulz@synopsys.com> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-17 18:50 ` [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Paul Zimmerman @ 2014-10-17 18:52 ` Felipe Balbi 2014-10-17 19:05 ` Paul Zimmerman 0 siblings, 1 reply; 12+ messages in thread From: Felipe Balbi @ 2014-10-17 18:52 UTC (permalink / raw) To: Paul Zimmerman Cc: Sudip Mukherjee, balbi@ti.com, Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1550 bytes --] On Fri, Oct 17, 2014 at 06:50:19PM +0000, Paul Zimmerman wrote: > > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > > Sent: Thursday, October 16, 2014 9:44 PM > > > > sparse was giving the following warning: > > warning: context imbalance in 's3c_hsotg_ep_enable' > > - different lock contexts for basic block > > > > we were returning ENOMEM while still holding the spinlock. > > The sparse warning was fixed by releasing the spinlock before return. > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > --- > > drivers/usb/dwc2/gadget.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > index 7b5856f..7f25527 100644 > > --- a/drivers/usb/dwc2/gadget.c > > +++ b/drivers/usb/dwc2/gadget.c > > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > hs_ep->fifo_size = val; > > break; > > } > > - if (i == 8) > > - return -ENOMEM; > > + if (i == 8) { > > + ret = -ENOMEM; > > + goto error; > > + } > > } > > > > /* for non control endpoints, set PID to D0 */ > > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > /* enable the endpoint interrupt */ > > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > > > +error: > > spin_unlock_irqrestore(&hsotg->lock, flags); > > return ret; > > } > > Acked-by: Paul Zimmerman <paulz@synopsys.com> v3.18-rc or v3.19 ? -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-17 18:52 ` Felipe Balbi @ 2014-10-17 19:05 ` Paul Zimmerman 2014-10-17 19:12 ` Felipe Balbi 2014-10-23 10:07 ` Sudip Mukherjee 0 siblings, 2 replies; 12+ messages in thread From: Paul Zimmerman @ 2014-10-17 19:05 UTC (permalink / raw) To: balbi@ti.com Cc: Sudip Mukherjee, Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org > From: Felipe Balbi [mailto:balbi@ti.com] > Sent: Friday, October 17, 2014 11:52 AM > > On Fri, Oct 17, 2014 at 06:50:19PM +0000, Paul Zimmerman wrote: > > > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > > > Sent: Thursday, October 16, 2014 9:44 PM > > > > > > sparse was giving the following warning: > > > warning: context imbalance in 's3c_hsotg_ep_enable' > > > - different lock contexts for basic block > > > > > > we were returning ENOMEM while still holding the spinlock. > > > The sparse warning was fixed by releasing the spinlock before return. > > > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > > --- > > > drivers/usb/dwc2/gadget.c | 7 +++++-- > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > > index 7b5856f..7f25527 100644 > > > --- a/drivers/usb/dwc2/gadget.c > > > +++ b/drivers/usb/dwc2/gadget.c > > > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > hs_ep->fifo_size = val; > > > break; > > > } > > > - if (i == 8) > > > - return -ENOMEM; > > > + if (i == 8) { > > > + ret = -ENOMEM; > > > + goto error; > > > + } > > > } > > > > > > /* for non control endpoints, set PID to D0 */ > > > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > /* enable the endpoint interrupt */ > > > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > > > > > +error: > > > spin_unlock_irqrestore(&hsotg->lock, flags); > > > return ret; > > > } > > > > Acked-by: Paul Zimmerman <paulz@synopsys.com> > > v3.18-rc or v3.19 ? v3.18-rc, since it's a bugfix. And I forgot, this should be marked for 3.17 stable too. -- Paul ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-17 19:05 ` Paul Zimmerman @ 2014-10-17 19:12 ` Felipe Balbi 2014-10-23 10:07 ` Sudip Mukherjee 1 sibling, 0 replies; 12+ messages in thread From: Felipe Balbi @ 2014-10-17 19:12 UTC (permalink / raw) To: Paul Zimmerman Cc: balbi@ti.com, Sudip Mukherjee, Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 2010 bytes --] On Fri, Oct 17, 2014 at 07:05:19PM +0000, Paul Zimmerman wrote: > > From: Felipe Balbi [mailto:balbi@ti.com] > > Sent: Friday, October 17, 2014 11:52 AM > > > > On Fri, Oct 17, 2014 at 06:50:19PM +0000, Paul Zimmerman wrote: > > > > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > > > > Sent: Thursday, October 16, 2014 9:44 PM > > > > > > > > sparse was giving the following warning: > > > > warning: context imbalance in 's3c_hsotg_ep_enable' > > > > - different lock contexts for basic block > > > > > > > > we were returning ENOMEM while still holding the spinlock. > > > > The sparse warning was fixed by releasing the spinlock before return. > > > > > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > > > --- > > > > drivers/usb/dwc2/gadget.c | 7 +++++-- > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > > > index 7b5856f..7f25527 100644 > > > > --- a/drivers/usb/dwc2/gadget.c > > > > +++ b/drivers/usb/dwc2/gadget.c > > > > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > hs_ep->fifo_size = val; > > > > break; > > > > } > > > > - if (i == 8) > > > > - return -ENOMEM; > > > > + if (i == 8) { > > > > + ret = -ENOMEM; > > > > + goto error; > > > > + } > > > > } > > > > > > > > /* for non control endpoints, set PID to D0 */ > > > > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > /* enable the endpoint interrupt */ > > > > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > > > > > > > +error: > > > > spin_unlock_irqrestore(&hsotg->lock, flags); > > > > return ret; > > > > } > > > > > > Acked-by: Paul Zimmerman <paulz@synopsys.com> > > > > v3.18-rc or v3.19 ? > > v3.18-rc, since it's a bugfix. And I forgot, this should be marked for > 3.17 stable too. Alright, I'll add that. -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-17 19:05 ` Paul Zimmerman 2014-10-17 19:12 ` Felipe Balbi @ 2014-10-23 10:07 ` Sudip Mukherjee 2014-10-23 10:17 ` Greg Kroah-Hartman 1 sibling, 1 reply; 12+ messages in thread From: Sudip Mukherjee @ 2014-10-23 10:07 UTC (permalink / raw) To: Paul Zimmerman Cc: balbi@ti.com, Greg Kroah-Hartman, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org On Fri, Oct 17, 2014 at 07:05:19PM +0000, Paul Zimmerman wrote: > > From: Felipe Balbi [mailto:balbi@ti.com] > > Sent: Friday, October 17, 2014 11:52 AM > > > > On Fri, Oct 17, 2014 at 06:50:19PM +0000, Paul Zimmerman wrote: > > > > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > > > > Sent: Thursday, October 16, 2014 9:44 PM > > > > > > > > sparse was giving the following warning: > > > > warning: context imbalance in 's3c_hsotg_ep_enable' > > > > - different lock contexts for basic block > > > > > > > > we were returning ENOMEM while still holding the spinlock. > > > > The sparse warning was fixed by releasing the spinlock before return. > > > > > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > > > --- > > > > drivers/usb/dwc2/gadget.c | 7 +++++-- > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > > > index 7b5856f..7f25527 100644 > > > > --- a/drivers/usb/dwc2/gadget.c > > > > +++ b/drivers/usb/dwc2/gadget.c > > > > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > hs_ep->fifo_size = val; > > > > break; > > > > } > > > > - if (i == 8) > > > > - return -ENOMEM; > > > > + if (i == 8) { > > > > + ret = -ENOMEM; > > > > + goto error; > > > > + } > > > > } > > > > > > > > /* for non control endpoints, set PID to D0 */ > > > > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > /* enable the endpoint interrupt */ > > > > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > > > > > > > +error: > > > > spin_unlock_irqrestore(&hsotg->lock, flags); > > > > return ret; > > > > } > > > > > > Acked-by: Paul Zimmerman <paulz@synopsys.com> > > > > v3.18-rc or v3.19 ? > > v3.18-rc, since it's a bugfix. And I forgot, this should be marked for > 3.17 stable too. > hi, this is not yet added to linux-next , is something pending from my side? thanks sudip > -- > Paul > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance 2014-10-23 10:07 ` Sudip Mukherjee @ 2014-10-23 10:17 ` Greg Kroah-Hartman 0 siblings, 0 replies; 12+ messages in thread From: Greg Kroah-Hartman @ 2014-10-23 10:17 UTC (permalink / raw) To: Sudip Mukherjee Cc: Paul Zimmerman, balbi@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org On Thu, Oct 23, 2014 at 03:37:14PM +0530, Sudip Mukherjee wrote: > On Fri, Oct 17, 2014 at 07:05:19PM +0000, Paul Zimmerman wrote: > > > From: Felipe Balbi [mailto:balbi@ti.com] > > > Sent: Friday, October 17, 2014 11:52 AM > > > > > > On Fri, Oct 17, 2014 at 06:50:19PM +0000, Paul Zimmerman wrote: > > > > > From: Sudip Mukherjee [mailto:sudipm.mukherjee@gmail.com] > > > > > Sent: Thursday, October 16, 2014 9:44 PM > > > > > > > > > > sparse was giving the following warning: > > > > > warning: context imbalance in 's3c_hsotg_ep_enable' > > > > > - different lock contexts for basic block > > > > > > > > > > we were returning ENOMEM while still holding the spinlock. > > > > > The sparse warning was fixed by releasing the spinlock before return. > > > > > > > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > > > > --- > > > > > drivers/usb/dwc2/gadget.c | 7 +++++-- > > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c > > > > > index 7b5856f..7f25527 100644 > > > > > --- a/drivers/usb/dwc2/gadget.c > > > > > +++ b/drivers/usb/dwc2/gadget.c > > > > > @@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > > hs_ep->fifo_size = val; > > > > > break; > > > > > } > > > > > - if (i == 8) > > > > > - return -ENOMEM; > > > > > + if (i == 8) { > > > > > + ret = -ENOMEM; > > > > > + goto error; > > > > > + } > > > > > } > > > > > > > > > > /* for non control endpoints, set PID to D0 */ > > > > > @@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep, > > > > > /* enable the endpoint interrupt */ > > > > > s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); > > > > > > > > > > +error: > > > > > spin_unlock_irqrestore(&hsotg->lock, flags); > > > > > return ret; > > > > > } > > > > > > > > Acked-by: Paul Zimmerman <paulz@synopsys.com> > > > > > > v3.18-rc or v3.19 ? > > > > v3.18-rc, since it's a bugfix. And I forgot, this should be marked for > > 3.17 stable too. > > > hi, > this is not yet added to linux-next , is something pending from my side? Patience. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-10-23 10:18 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-10-17 4:44 [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Sudip Mukherjee 2014-10-17 4:44 ` [PATCH v3 2/2] usb: dwc2: gadget: modify return statement Sudip Mukherjee 2014-10-17 9:02 ` David Laight 2014-10-17 10:03 ` Sudip Mukherjee 2014-10-17 18:10 ` Paul Zimmerman 2014-10-17 18:52 ` Paul Zimmerman 2014-10-17 18:50 ` [PATCH v3 1/2] usb: dwc2: gadget: sparse warning of context imbalance Paul Zimmerman 2014-10-17 18:52 ` Felipe Balbi 2014-10-17 19:05 ` Paul Zimmerman 2014-10-17 19:12 ` Felipe Balbi 2014-10-23 10:07 ` Sudip Mukherjee 2014-10-23 10:17 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox