public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Tanmay Inamdar <tinamdar@apm.com>, Duc Dang <dhdang@apm.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] PCI: xgene: double free on init error
Date: Tue, 31 Jan 2017 00:18:15 +0000	[thread overview]
Message-ID: <20170131001815.GD20550@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20170121044949.GB15269@mwanda>

On Sat, Jan 21, 2017 at 07:49:49AM +0300, Dan Carpenter wrote:
> The "port" variable was allocated with devm_kzalloc() so if we free it
> with kfree() it will be freed twice.  Also I changed it to propogate the
> error from devm_ioremap_resource() instead of returning -ENOMEM.
> 
> Fixes: c5d460396100 ("PCI: Add MCFG quirks for X-Gene host controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied with Tanmay's ack to pci/host-xgene for v4.11, thanks!

> diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
> index 7c3b54b..142a166 100644
> --- a/drivers/pci/host/pci-xgene.c
> +++ b/drivers/pci/host/pci-xgene.c
> @@ -246,14 +246,11 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion)
>  	ret = xgene_get_csr_resource(adev, &csr);
>  	if (ret) {
>  		dev_err(dev, "can't get CSR resource\n");
> -		kfree(port);
>  		return ret;
>  	}
>  	port->csr_base = devm_ioremap_resource(dev, &csr);
> -	if (IS_ERR(port->csr_base)) {
> -		kfree(port);
> -		return -ENOMEM;
> -	}
> +	if (IS_ERR(port->csr_base))
> +		return PTR_ERR(port->csr_base);
>  
>  	port->cfg_base = cfg->win;
>  	port->version = ipversion;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2017-01-31  0:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-21  4:49 [patch] PCI: xgene: double free on init error Dan Carpenter
2017-01-30 23:03 ` Bjorn Helgaas
2017-01-30 23:17   ` Tanmay Inamdar
2017-01-31  0:18 ` 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=20170131001815.GD20550@bhelgaas-glaptop.roam.corp.google.com \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dhdang@apm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=tinamdar@apm.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