* [patch] usb: gadget: f_midi: missing unlock on error path
@ 2015-12-21 13:20 Dan Carpenter
2015-12-22 16:51 ` Felipe Ferreri Tonello
2015-12-22 18:22 ` SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2015-12-21 13:20 UTC (permalink / raw)
To: kernel-janitors
We added a new error path to this function and we forgot to drop the
lock.
Fixes: e1e3d7ec5da3 ('usb: gadget: f_midi: pre-allocate IN requests')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index fb1fe96d..92b9ec8 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1213,8 +1213,10 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
midi->in_last_port = 0;
status = kfifo_alloc(&midi->in_req_fifo, midi->qlen, GFP_KERNEL);
- if (status)
+ if (status) {
+ mutex_unlock(&opts->lock);
goto setup_fail;
+ }
++opts->refcnt;
mutex_unlock(&opts->lock);
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [patch] usb: gadget: f_midi: missing unlock on error path
2015-12-21 13:20 [patch] usb: gadget: f_midi: missing unlock on error path Dan Carpenter
@ 2015-12-22 16:51 ` Felipe Ferreri Tonello
2015-12-22 18:22 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Felipe Ferreri Tonello @ 2015-12-22 16:51 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]
Hi Dan,
On 21/12/15 13:20, Dan Carpenter wrote:
> We added a new error path to this function and we forgot to drop the
> lock.
>
> Fixes: e1e3d7ec5da3 ('usb: gadget: f_midi: pre-allocate IN requests')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
> index fb1fe96d..92b9ec8 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -1213,8 +1213,10 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
> midi->in_last_port = 0;
>
> status = kfifo_alloc(&midi->in_req_fifo, midi->qlen, GFP_KERNEL);
> - if (status)
> + if (status) {
> + mutex_unlock(&opts->lock);
This is fine. But looking into this further, I believe this mutex_unlock
should be under the setup_fail label, because even if the alloc() fails,
it will be need to unlock the mutex in any circumstance anyway.
> goto setup_fail;
> + }
>
> ++opts->refcnt;
> mutex_unlock(&opts->lock);
>
Felipe
[-- Attachment #2: 0x92698E6A.asc --]
[-- Type: application/pgp-keys, Size: 7310 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch] usb: gadget: f_midi: missing unlock on error path
2015-12-21 13:20 [patch] usb: gadget: f_midi: missing unlock on error path Dan Carpenter
2015-12-22 16:51 ` Felipe Ferreri Tonello
@ 2015-12-22 18:22 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2015-12-22 18:22 UTC (permalink / raw)
To: kernel-janitors
> We added a new error path to this function and we forgot to drop the lock.
>
> Fixes: e1e3d7ec5da3 ('usb: gadget: f_midi: pre-allocate IN requests')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
> index fb1fe96d..92b9ec8 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -1213,8 +1213,10 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
> midi->in_last_port = 0;
>
> status = kfifo_alloc(&midi->in_req_fifo, midi->qlen, GFP_KERNEL);
> - if (status)
> + if (status) {
> + mutex_unlock(&opts->lock);
> goto setup_fail;
> + }
>
> ++opts->refcnt;
> mutex_unlock(&opts->lock);
How do you think about to move this unlock call and the one that belongs to
the handling of a kstrdup() failure below the shown jump target?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-22 18:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-21 13:20 [patch] usb: gadget: f_midi: missing unlock on error path Dan Carpenter
2015-12-22 16:51 ` Felipe Ferreri Tonello
2015-12-22 18:22 ` SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox