public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Ferreri Tonello <eu@felipetonello.com>
To: Michal Nazarewicz <mina86@mina86.com>,
	Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dan Carpenter <dan.carpenter@oracle.com>
Cc: Robert Baldyga <r.baldyga@samsung.com>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Pawel Szewczyk <p.szewczyk@samsung.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: gadget: f_midi: missing unlock on error path
Date: Wed, 13 Jan 2016 18:29:46 +0000	[thread overview]
Message-ID: <5696979A.7070204@felipetonello.com> (raw)
In-Reply-To: <1452311230-21431-2-git-send-email-mina86@mina86.com>

[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]

Hi Dan,

On 09/01/16 03:47, Michal Nazarewicz wrote:
> 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>

Reviewed-by: Felipe F. Tonello <eu@felipetonello.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);
>  }
> 

[-- Attachment #2: 0x92698E6A.asc --]
[-- Type: application/pgp-keys, Size: 7195 bytes --]

  reply	other threads:[~2016-01-13 18:29 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 ` [PATCH 2/2] usb: gadget: f_midi: missing unlock on error path Michal Nazarewicz
2016-01-13 18:29   ` Felipe Ferreri Tonello [this message]
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=5696979A.7070204@felipetonello.com \
    --to=eu@felipetonello.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.com \
    --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