linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] EDAC: Fix memory leak in i5100_init_one
@ 2019-11-21 19:40 Navid Emamdoost
  2019-11-21 20:39 ` Robert Richter
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-11-21 19:40 UTC (permalink / raw)
  To: Borislav Petkov, Mauro Carvalho Chehab, Tony Luck, James Morse,
	Robert Richter, linux-edac, linux-kernel
  Cc: emamd001, Navid Emamdoost

In the implementation of i5100_init_one(), the allocated mci is not
correctly released in cases of failure. The release via edac_mc_free()
should be reached by label bail_einj and subsequents.

Fixes: 52608ba20546 ("i5100_edac: probe for device 19 function 0")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/edac/i5100_edac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 251f2b692785..710fabd5fba1 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -1149,12 +1149,12 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 bail_scrub:
 	priv->scrub_enable = 0;
 	cancel_delayed_work_sync(&(priv->i5100_scrubbing));
-	edac_mc_free(mci);
 
 bail_disable_einj:
 	pci_disable_device(einj);
 
 bail_einj:
+	edac_mc_free(mci);
 	pci_dev_put(einj);
 
 bail_disable_ch1:
-- 
2.17.1


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

* Re: [PATCH] EDAC: Fix memory leak in i5100_init_one
  2019-11-21 19:40 [PATCH] EDAC: Fix memory leak in i5100_init_one Navid Emamdoost
@ 2019-11-21 20:39 ` Robert Richter
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Richter @ 2019-11-21 20:39 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Borislav Petkov, Mauro Carvalho Chehab, Tony Luck, James Morse,
	linux-edac, linux-kernel, emamd001

On 21.11.19 13:40:41, Navid Emamdoost wrote:
> In the implementation of i5100_init_one(), the allocated mci is not
> correctly released in cases of failure. The release via edac_mc_free()
> should be reached by label bail_einj and subsequents.
> 
> Fixes: 52608ba20546 ("i5100_edac: probe for device 19 function 0")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/edac/i5100_edac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
> index 251f2b692785..710fabd5fba1 100644
> --- a/drivers/edac/i5100_edac.c
> +++ b/drivers/edac/i5100_edac.c
> @@ -1149,12 +1149,12 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
>  bail_scrub:
>  	priv->scrub_enable = 0;
>  	cancel_delayed_work_sync(&(priv->i5100_scrubbing));
> -	edac_mc_free(mci);
>  
>  bail_disable_einj:
>  	pci_disable_device(einj);
>  
>  bail_einj:
> +	edac_mc_free(mci);
>  	pci_dev_put(einj);

The whole error path looks broken:

bail_disable_einj: may *not* call pci_disable_device().

bail_einj: may not call pci_dev_put()

i5100_setup_debugfs() may fail.

etc.

All needs to be fixed. Please review the error path.

Thanks,

-Robert

>  
>  bail_disable_ch1:
> -- 
> 2.17.1
> 

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

end of thread, other threads:[~2019-11-21 20:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 19:40 [PATCH] EDAC: Fix memory leak in i5100_init_one Navid Emamdoost
2019-11-21 20:39 ` Robert Richter

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).