Linux-EDAC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] EDAC: i5100_edac: Fix error handling code in i5100_init_one
@ 2020-08-26 12:14 Dinghao Liu
  2020-09-01 10:13 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-08-26 12:14 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Borislav Petkov, Mauro Carvalho Chehab, Tony Luck, James Morse,
	Robert Richter, Niklas Söderlund, linux-edac, linux-kernel

When pci_get_device_func() fails, we don't need to execute
pci_dev_put(). But mci should be freed to prevent memleak.
When pci_enable_device() fails, we don't need to disable
einj either.

Fixes: 52608ba205461 ("i5100_edac: probe for device 19 function 0")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/edac/i5100_edac.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 191aa7c19ded..410bbe55cd3f 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -1061,13 +1061,13 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 				    PCI_DEVICE_ID_INTEL_5100_19, 0);
 	if (!einj) {
 		ret = -ENODEV;
-		goto bail_einj;
+		goto bail_free;
 	}
 
 	rc = pci_enable_device(einj);
 	if (rc < 0) {
 		ret = rc;
-		goto bail_disable_einj;
+		goto bail_einj;
 	}
 
 
@@ -1136,14 +1136,14 @@ 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:
 	pci_dev_put(einj);
 
+bail_free:
+	edac_mc_free(mci);
+
 bail_disable_ch1:
 	pci_disable_device(ch1mm);
 
-- 
2.17.1


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

* Re: [PATCH] EDAC: i5100_edac: Fix error handling code in i5100_init_one
  2020-08-26 12:14 [PATCH] EDAC: i5100_edac: Fix error handling code in i5100_init_one Dinghao Liu
@ 2020-09-01 10:13 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2020-09-01 10:13 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Mauro Carvalho Chehab, Tony Luck, James Morse,
	Robert Richter, Niklas Söderlund, linux-edac, linux-kernel

On Wed, Aug 26, 2020 at 08:14:37PM +0800, Dinghao Liu wrote:
> When pci_get_device_func() fails, we don't need to execute
> pci_dev_put(). But mci should be freed to prevent memleak.
> When pci_enable_device() fails, we don't need to disable
> einj either.
> 
> Fixes: 52608ba205461 ("i5100_edac: probe for device 19 function 0")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/edac/i5100_edac.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 12:14 [PATCH] EDAC: i5100_edac: Fix error handling code in i5100_init_one Dinghao Liu
2020-09-01 10:13 ` Borislav Petkov

Linux-EDAC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-edac/0 linux-edac/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-edac linux-edac/ https://lore.kernel.org/linux-edac \
		linux-edac@vger.kernel.org
	public-inbox-index linux-edac

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-edac


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git