From: Michal Nazarewicz <mina86@mina86.com>
To: Felipe Balbi <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Felipe F. Tonello" <eu@felipetonello.com>,
Robert Baldyga <r.baldyga@samsung.com>,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
Pawel Szewczyk <p.szewczyk@samsung.com>,
linux-kernel@vger.kernel.org,
Michal Nazarewicz <mina86@mina86.com>
Subject: [PATCH 2/2] usb: gadget: f_midi: missing unlock on error path
Date: Sat, 9 Jan 2016 04:47:10 +0100 [thread overview]
Message-ID: <1452311230-21431-2-git-send-email-mina86@mina86.com> (raw)
In-Reply-To: <1452311230-21431-1-git-send-email-mina86@mina86.com>
From: Dan Carpenter <dan.carpenter@oracle.com>
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>
[mina86@mina86.com: rebased on top of refactoring commit]
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
drivers/usb/gadget/function/f_midi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index fd67af2..f287c68 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1098,7 +1098,7 @@ static void f_midi_unbind(struct usb_configuration *c, struct usb_function *f)
static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
{
- struct f_midi *midi;
+ struct f_midi *midi = NULL;
struct f_midi_opts *opts;
int status, i;
@@ -1107,8 +1107,8 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
mutex_lock(&opts->lock);
/* sanity check */
if (opts->in_ports > MAX_PORTS || opts->out_ports > MAX_PORTS) {
- mutex_unlock(&opts->lock);
- return ERR_PTR(-EINVAL);
+ status = -EINVAL;
+ goto setup_fail;
}
/* allocate and initialize one new instance */
@@ -1116,8 +1116,8 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
sizeof(*midi) + opts->in_ports * sizeof(*midi->in_ports_array),
GFP_KERNEL);
if (!midi) {
- mutex_unlock(&opts->lock);
- return ERR_PTR(-ENOMEM);
+ status = -ENOMEM;
+ goto setup_fail;
}
for (i = 0; i < opts->in_ports; i++)
@@ -1127,7 +1127,6 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
midi->id = kstrdup(opts->id, GFP_KERNEL);
if (opts->id && !midi->id) {
status = -ENOMEM;
- mutex_unlock(&opts->lock);
goto setup_fail;
}
midi->in_ports = opts->in_ports;
@@ -1148,6 +1147,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
return &midi->func;
setup_fail:
+ mutex_unlock(&opts->lock);
kfree(midi);
return ERR_PTR(status);
}
--
2.6.0.rc2.230.g3dd15c0
next prev parent reply other threads:[~2016-01-09 3:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-09 3:47 [PATCHv2 1/2] usb: gadget: f_midi: use flexible array member for gmidi_in_port elements Michal Nazarewicz
2016-01-09 3:47 ` Michal Nazarewicz [this message]
2016-01-13 18:29 ` [PATCH 2/2] usb: gadget: f_midi: missing unlock on error path Felipe Ferreri Tonello
2016-01-13 18:26 ` [PATCHv2 1/2] usb: gadget: f_midi: use flexible array member for gmidi_in_port elements Felipe Ferreri Tonello
2016-01-13 20:41 ` Dan Carpenter
2016-01-18 16:02 ` Michal Nazarewicz
2016-01-19 9:46 ` Felipe Ferreri Tonello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452311230-21431-2-git-send-email-mina86@mina86.com \
--to=mina86@mina86.com \
--cc=andrzej.p@samsung.com \
--cc=balbi@ti.com \
--cc=dan.carpenter@oracle.com \
--cc=eu@felipetonello.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.szewczyk@samsung.com \
--cc=r.baldyga@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®