From: Bjorn Helgaas <bhelgaas@google.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: linux-pci@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH] drivers: of: fix resources freeing in of_pci_get_host_bridge_resources()
Date: Wed, 28 Jan 2015 17:13:02 -0600 [thread overview]
Message-ID: <20150128231302.GB17623@google.com> (raw)
In-Reply-To: <1422381705-5380-1-git-send-email-lorenzo.pieralisi@arm.com>
On Tue, Jan 27, 2015 at 06:01:45PM +0000, Lorenzo Pieralisi wrote:
> In the function of_pci_get_host_bridge_resources() if the parsing of
> ranges fails, previously allocated resources inclusive of bus_range
> are not freed and are not expected to be freed by the function caller
> on error return.
>
> This patch fixes the issues by adding code that properly frees resources
> and bus_range before exiting the function with an error return value.
>
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Liviu Dudau <liviu.dudau@arm.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Rob Herring <robh+dt@kernel.org>
Applied to pci/host-generic for v3.20, thanks!
> ---
> drivers/of/of_pci.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
> index 88471d3..60dc36c 100644
> --- a/drivers/of/of_pci.c
> +++ b/drivers/of/of_pci.c
> @@ -140,6 +140,7 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
> unsigned char busno, unsigned char bus_max,
> struct list_head *resources, resource_size_t *io_base)
> {
> + struct pci_host_bridge_window *window;
> struct resource *res;
> struct resource *bus_range;
> struct of_pci_range range;
> @@ -225,7 +226,10 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
> conversion_failed:
> kfree(res);
> parse_failed:
> + list_for_each_entry(window, resources, list)
> + kfree(window->res);
> pci_free_resource_list(resources);
> + kfree(bus_range);
> return err;
> }
> EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);
> --
> 2.2.1
>
prev parent reply other threads:[~2015-01-28 23:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 18:01 [PATCH] drivers: of: fix resources freeing in of_pci_get_host_bridge_resources() Lorenzo Pieralisi
2015-01-28 23:13 ` Bjorn Helgaas [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=20150128231302.GB17623@google.com \
--to=bhelgaas@google.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).