All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Djalal Harouni <tixxdz@opendz.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: fix a memory leak of pci_host_bridge on error path
Date: Wed, 29 Jan 2014 16:12:22 -0700	[thread overview]
Message-ID: <20140129231222.GI16825@google.com> (raw)
In-Reply-To: <1389741079-12976-1-git-send-email-tixxdz@opendz.org>

On Wed, Jan 15, 2014 at 12:11:19AM +0100, Djalal Harouni wrote:
> On error paths make sure that the pci_host_bridge struct is freed.
> 
> Signed-off-by: Djalal Harouni <tixxdz@opendz.org>

Applied to pci/misc, thanks!

> ---
> On top of linux-next.
> 
>  drivers/pci/probe.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 23cdfac..483566c 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1771,15 +1771,13 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>  	error = pcibios_root_bridge_prepare(bridge);
> -	if (error) {
> -		kfree(bridge);
> -		goto err_out;
> -	}
> +	if (error)
> +		goto host_bridge_err;
>  
>  	error = device_register(&bridge->dev);
>  	if (error) {
>  		put_device(&bridge->dev);
> -		goto err_out;
> +		goto host_bridge_err;
>  	}
>  	b->bridge = get_device(&bridge->dev);
>  	device_enable_async_suspend(b->bridge);
> @@ -1836,6 +1834,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  class_dev_reg_err:
>  	put_device(&bridge->dev);
>  	device_unregister(&bridge->dev);
> +host_bridge_err:
> +	kfree(bridge);
>  err_out:
>  	kfree(b);
>  	return NULL;
> -- 
> 1.7.11.7
> 

  reply	other threads:[~2014-01-29 23:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14 23:11 [PATCH] PCI: fix a memory leak of pci_host_bridge on error path Djalal Harouni
2014-01-29 23:12 ` Bjorn Helgaas [this message]
2014-01-30  0:23   ` Yinghai Lu
2014-01-30  0:46     ` Bjorn Helgaas

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=20140129231222.GI16825@google.com \
    --to=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=tixxdz@opendz.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.