From: Catalin Marinas <catalin.marinas@arm.com>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Alex Dubov <oakad@yahoo.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kay Sievers <kay.sievers@vrfy.org>,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: [PATCH] memstick: Fix memory leak in memstick_check() error path
Date: Mon, 7 Oct 2013 09:48:48 +0100 [thread overview]
Message-ID: <20131007084848.GA32012@arm.com> (raw)
In-Reply-To: <5251FA23.1080504@lwfinger.net>
On Mon, Oct 07, 2013 at 01:02:43AM +0100, Larry Finger wrote:
> On 10/04/2013 03:54 AM, Catalin Marinas wrote:
> > On 3 October 2013 22:13, Larry Finger <Larry.Finger@lwfinger.net> wrote:
> >> diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
> >> index ffcb10a..0c73a45 100644
> >> --- a/drivers/memstick/core/memstick.c
> >> +++ b/drivers/memstick/core/memstick.c
> >> @@ -415,6 +415,7 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
> >> return card;
> >> err_out:
> >> host->card = old_card;
> >> + kfree(card->dev.kobj.name);
> >
> > It looks weird to go into dev.kobj internals here for freeing the
> > name. There is also memstick_free_card() which doesn't seem to do
> > anything about the name freeing.
> >
> > Should memstick_alloc_card() do a device_initialise(&card->dev) and in
> > memstick_free_card() (or the error path) do a put_device(&card->dev)?
> > This should take care of kobj.name as well via kobject_put().
>
> I tried several code changes that included adding a device_initialize() call,
> but all of them oopsed even when I followed the examples in other drivers.
> Adding a put_device() without the device_initialize() did not oops, but it still
> leaked the name.
>
> We could avoid going into the dev.kobj internals if a device_free_name() routine
> existed as a companion to dev_set_name().
device_free_name() wouldn't be a bad idea.
--
Catalin
next prev parent reply other threads:[~2013-10-07 8:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-03 21:13 [PATCH] memstick: Fix memory leak in memstick_check() error path Larry Finger
2013-10-04 8:54 ` Catalin Marinas
2013-10-07 0:02 ` Larry Finger
2013-10-07 1:57 ` Alex Dubov
2013-10-07 3:17 ` Larry Finger
2013-10-07 8:48 ` Catalin Marinas [this message]
2013-10-08 2:13 ` [PATCH V2] " Greg Kroah-Hartman
2013-10-08 3:12 ` Larry Finger
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=20131007084848.GA32012@arm.com \
--to=catalin.marinas@arm.com \
--cc=Larry.Finger@lwfinger.net \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oakad@yahoo.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