Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754447AbbL3TIJ (ORCPT ); Wed, 30 Dec 2015 14:08:09 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:38698 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751276AbbL3THw (ORCPT ); Wed, 30 Dec 2015 14:07:52 -0500 From: "Felipe F. Tonello" To: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Robert Baldyga , Greg Kroah-Hartman , Clemens Ladisch Subject: [PATCH 4/4] usb: gadget: f_midi: add mutex_unlock under setup_fail label Date: Wed, 30 Dec 2015 19:07:55 +0000 Message-Id: <1451502475-22794-5-git-send-email-eu@felipetonello.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1451502475-22794-1-git-send-email-eu@felipetonello.com> References: <1451502475-22794-1-git-send-email-eu@felipetonello.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1442 Lines: 44 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 --- 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/