public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch 2/2 -next] USB: gadget: midi: memory leak in
Date: Tue, 18 Oct 2011 06:25:34 +0000	[thread overview]
Message-ID: <20111018062534.GM27732@elgon.mountain> (raw)

There is a small memory leak on the error paths.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c
index ef1bc7a..67b2229 100644
--- a/drivers/usb/gadget/f_midi.c
+++ b/drivers/usb/gadget/f_midi.c
@@ -951,7 +951,7 @@ int __init f_midi_bind_config(struct usb_configuration *c,
 		struct gmidi_in_port *port = kzalloc(sizeof(*port), GFP_KERNEL);
 		if (!port) {
 			status = -ENOMEM;
-			goto fail;
+			goto setup_fail;
 		}
 
 		port->midi = midi;
@@ -989,6 +989,8 @@ int __init f_midi_bind_config(struct usb_configuration *c,
 	return 0;
 
 setup_fail:
+	for (--i; i >= 0; i--)
+		kfree(midi->in_port[i]);
 	kfree(midi);
 fail:
 	return status;

                 reply	other threads:[~2011-10-18  6:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20111018062534.GM27732@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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