All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] PCI: xgene: double free on init error
@ 2017-01-21  4:49 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2017-01-21  4:49 UTC (permalink / raw)
  To: Tanmay Inamdar, Duc Dang; +Cc: Bjorn Helgaas, linux-pci, kernel-janitors

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>

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;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [patch] PCI: xgene: double free on init error
@ 2017-01-21  4:49 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2017-01-21  4:49 UTC (permalink / raw)
  To: Tanmay Inamdar, Duc Dang; +Cc: Bjorn Helgaas, linux-pci, kernel-janitors

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>

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;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
  2017-01-21  4:49 ` Dan Carpenter
@ 2017-01-30 23:03   ` Bjorn Helgaas
  -1 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2017-01-30 23:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tanmay Inamdar, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

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>

Waiting for Tanmay's ack, ping :)

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
@ 2017-01-30 23:03   ` Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2017-01-30 23:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tanmay Inamdar, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

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>

Waiting for Tanmay's ack, ping :)

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
  2017-01-30 23:03   ` Bjorn Helgaas
@ 2017-01-30 23:17     ` Tanmay Inamdar
  -1 siblings, 0 replies; 8+ messages in thread
From: Tanmay Inamdar @ 2017-01-30 23:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Dan Carpenter, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

Hi,

On Mon, Jan 30, 2017 at 3:03 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> 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>
>
> Waiting for Tanmay's ack, ping :)
>
> > 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;

Sorry for delay. Patch looks good to me. Thanks.

Acked-by: Tanmay Inamdar <tinamdar@apm.com>

Thanks,
Tanmay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
@ 2017-01-30 23:17     ` Tanmay Inamdar
  0 siblings, 0 replies; 8+ messages in thread
From: Tanmay Inamdar @ 2017-01-30 23:17 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Dan Carpenter, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

Hi,

On Mon, Jan 30, 2017 at 3:03 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> 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>
>
> Waiting for Tanmay's ack, ping :)
>
> > 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;

Sorry for delay. Patch looks good to me. Thanks.

Acked-by: Tanmay Inamdar <tinamdar@apm.com>

Thanks,
Tanmay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
  2017-01-21  4:49 ` Dan Carpenter
@ 2017-01-31  0:18   ` Bjorn Helgaas
  -1 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2017-01-31  0:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tanmay Inamdar, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] PCI: xgene: double free on init error
@ 2017-01-31  0:18   ` Bjorn Helgaas
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2017-01-31  0:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tanmay Inamdar, Duc Dang, Bjorn Helgaas, linux-pci, kernel-janitors

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-01-31  0:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-21  4:49 [patch] PCI: xgene: double free on init error Dan Carpenter
2017-01-21  4:49 ` Dan Carpenter
2017-01-30 23:03 ` Bjorn Helgaas
2017-01-30 23:03   ` Bjorn Helgaas
2017-01-30 23:17   ` Tanmay Inamdar
2017-01-30 23:17     ` Tanmay Inamdar
2017-01-31  0:18 ` Bjorn Helgaas
2017-01-31  0:18   ` Bjorn Helgaas

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.