linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaejoong Kim <climbbb.kim@gmail.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Krzysztof Opasiak <k.opasiak@samsung.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Subject: [1/3] usb: gadget: storage: Fix reference count if fsg_alloc_inst() failed
Date: Thu, 14 Jun 2018 18:23:57 +0900	[thread overview]
Message-ID: <1528968239-2447-2-git-send-email-climbbb.kim@gmail.com> (raw)

The reference count is initialized in fsg_alloc_inst(). So if
fsg_alloc_inst() fails, we need to add kref_put() to free an
allocated memory.

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
---
 drivers/usb/gadget/function/f_mass_storage.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index acecd13..83eeafe 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3392,6 +3392,7 @@ static struct usb_function_instance *fsg_alloc_inst(void)
 release_buffers:
 	fsg_common_free_buffers(opts->common);
 release_opts:
+	fsg_common_put(opts->common);
 	kfree(opts);
 	return ERR_PTR(rc);
 }

             reply	other threads:[~2018-06-14  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-14  9:23 Jaejoong Kim [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-06-14 14:55 [1/3] usb: gadget: storage: Fix reference count if fsg_alloc_inst() failed Alan Stern
2018-06-26  9:04 Michał Nazarewicz

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=1528968239-2447-2-git-send-email-climbbb.kim@gmail.com \
    --to=climbbb.kim@gmail.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=k.opasiak@samsung.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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;
as well as URLs for NNTP newsgroup(s).