From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
Ming Lei <tom.leiming@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Possible memory leak in request_firmware()
Date: Tue, 7 Jul 2009 19:01:25 +0200 [thread overview]
Message-ID: <20090707190125.61920d00@gondolin> (raw)
In-Reply-To: <1246979820.9451.71.camel@pc1117.cambridge.arm.com>
On Tue, 07 Jul 2009 16:17:00 +0100,
Catalin Marinas <catalin.marinas@arm.com> wrote:
> The patch below may fix the problem but it's only later tonight that I
> can test it and confirm:
Your patch looks fine to me (didn't test it either), just one minor nit:
>
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index ddeb819..12e6e64 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -357,7 +357,7 @@ static void fw_dev_release(struct device *dev)
> kfree(fw_priv->pages);
> kfree(fw_priv->fw_id);
> kfree(fw_priv);
> - put_device(dev);
> + kfree(dev);
>
> module_put(THIS_MODULE);
> }
> @@ -407,14 +407,13 @@ static int fw_register_device(struct device **dev_p, const char *fw_name,
> retval = device_register(f_dev);
> if (retval) {
> dev_err(device, "%s: device_register failed\n", __func__);
> + kfree(fw_priv->fw_id);
fw_priv->fw_id will be freed in the release function, so you don't need
to free it here.
> put_device(f_dev);
> - goto error_kfree_fw_id;
> + return retval;
> }
> *dev_p = f_dev;
> return 0;
>
> -error_kfree_fw_id:
> - kfree(fw_priv->fw_id);
> error_kfree:
> kfree(f_dev);
> kfree(fw_priv);
>
>
next prev parent reply other threads:[~2009-07-07 17:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-07 15:17 Possible memory leak in request_firmware() Catalin Marinas
2009-07-07 17:01 ` Cornelia Huck [this message]
2009-07-07 21:50 ` Catalin Marinas
2009-07-08 4:38 ` Ming Lei
2009-07-08 6:28 ` David Woodhouse
2009-07-08 8:42 ` Ming Lei
2009-07-08 8:56 ` David Woodhouse
2009-07-08 0:18 ` Ming Lei
2009-07-10 17:36 ` Greg KH
2009-07-10 22:49 ` Catalin Marinas
2009-07-10 22:56 ` Greg KH
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=20090707190125.61920d00@gondolin \
--to=cornelia.huck@de.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.leiming@gmail.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