From: Wei Yongjun <yongjun_...@trendmicro.com.cn>

Add the missing unlock before return from function f_midi_alloc()
when kfifo_alloc() failed.

Signed-off-by: Wei Yongjun <yongjun_...@trendmicro.com.cn>
---
 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 fb1fe96d..18119f3 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1188,7 +1188,6 @@ static struct usb_function *f_midi_alloc(struct 
usb_function_instance *fi)
 
                if (!port) {
                        status = -ENOMEM;
-                       mutex_unlock(&opts->lock);
                        goto setup_fail;
                }
 
@@ -1202,7 +1201,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;
@@ -1229,6 +1227,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);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to