From: "Felipe F. Tonello" <eu@felipetonello.com>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Felipe Balbi <balbi@ti.com>,
Robert Baldyga <r.baldyga@samsung.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Clemens Ladisch <clemens@ladisch.de>
Subject: [PATCH 4/4] usb: gadget: f_midi: add mutex_unlock under setup_fail label
Date: Wed, 30 Dec 2015 19:07:55 +0000 [thread overview]
Message-ID: <1451502475-22794-5-git-send-email-eu@felipetonello.com> (raw)
In-Reply-To: <1451502475-22794-1-git-send-email-eu@felipetonello.com>
This ensures that at any point on the function if a goto to setup_fail is
made, it will unlock the mutex.
Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
drivers/usb/gadget/function/f_midi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
index b7d3f5a10bf0..1255f8a898d0 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1251,7 +1251,6 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
if (!port) {
status = -ENOMEM;
- mutex_unlock(&opts->lock);
goto setup_fail;
}
@@ -1264,7 +1263,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;
@@ -1293,6 +1291,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
return &midi->func;
setup_fail:
+ mutex_unlock(&opts->lock);
for (--i; i >= 0; i--)
kfree(midi->in_port[i]);
kfree(midi);
--
2.6.4
prev parent reply other threads:[~2015-12-30 19:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-30 19:07 [PATCH 0/4] More improvements on MIDI gadget function Felipe F. Tonello
2015-12-30 19:07 ` [PATCH 1/4] usb: gadget: f_midi: refactor state machine Felipe F. Tonello
2015-12-30 19:07 ` [PATCH 2/4] usb: gadget: f_midi: added spinlock on transmit function Felipe F. Tonello
2015-12-30 19:07 ` [PATCH 3/4] usb: gadget: f_midi: remove useless midi reference from port struct Felipe F. Tonello
2015-12-30 19:07 ` Felipe F. Tonello [this message]
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=1451502475-22794-5-git-send-email-eu@felipetonello.com \
--to=eu@felipetonello.com \
--cc=balbi@ti.com \
--cc=clemens@ladisch.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--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®