Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1299461

[PATCH 4/4] usb: gadget: f_midi: add mutex_unlock under setup_fail label

From "Felipe F. Tonello" <eu@felipetonello.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] usb: gadget: f_midi: add mutex_unlock under setup_fail label
Date 2015-12-30 20:10 +0100
Message-ID <qLuif-2ad-45@gated-at.bofh.it> (permalink)
References <qLuie-2ad-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] More improvements on MIDI gadget function "Felipe F. Tonello" <eu@felipetonello.com> - 2015-12-30 20:10 +0100
  [PATCH 2/4] usb: gadget: f_midi: added spinlock on transmit function "Felipe F. Tonello" <eu@felipetonello.com> - 2015-12-30 20:10 +0100
  [PATCH 1/4] usb: gadget: f_midi: refactor state machine "Felipe F. Tonello" <eu@felipetonello.com> - 2015-12-30 20:10 +0100
  [PATCH 3/4] usb: gadget: f_midi: remove useless midi reference from port struct "Felipe F. Tonello" <eu@felipetonello.com> - 2015-12-30 20:10 +0100
  [PATCH 4/4] usb: gadget: f_midi: add mutex_unlock under setup_fail label "Felipe F. Tonello" <eu@felipetonello.com> - 2015-12-30 20:10 +0100

csiph-web