From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Vasiliy Kulikov <segoon@openwall.com>
Cc: kernel-janitors@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] power: power_supply_core: fix use after free and memory leak
Date: Wed, 22 Dec 2010 03:05:45 +0300 [thread overview]
Message-ID: <20101222000545.GC24834@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <1290192119-11704-1-git-send-email-segoon@openwall.com>
On Fri, Nov 19, 2010 at 09:41:58PM +0300, Vasiliy Kulikov wrote:
> device_unregister() might free its argument. This leads to freed
> memory use in kfree(). Also use put_device() instead of kfree()
> as dev may be already used in another layer after call to device_add().
>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Applied, thanks!
> ---
> Compile tested only.
>
> drivers/power/power_supply_core.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
> index 91606bb..f06bad0 100644
> --- a/drivers/power/power_supply_core.c
> +++ b/drivers/power/power_supply_core.c
> @@ -190,10 +190,10 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
> goto success;
>
> create_triggers_failed:
> - device_unregister(psy->dev);
> + device_del(dev);
> kobject_set_name_failed:
> device_add_failed:
> - kfree(dev);
> + put_device(dev);
> success:
> return rc;
> }
> --
> 1.7.0.4
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
prev parent reply other threads:[~2010-12-22 0:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 18:41 [PATCH] power: power_supply_core: fix use after free and memory leak Vasiliy Kulikov
2010-12-22 0:05 ` Anton Vorontsov [this message]
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=20101222000545.GC24834@oksana.dev.rtsoft.ru \
--to=cbouatmailru@gmail.com \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segoon@openwall.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