Skip to content

Commit 857a313

Browse files
dinghaoliusuryasaimadhu
authored andcommitted
EDAC/i5100: Fix error handling order in i5100_init_one()
When pci_get_device_func() fails, the driver doesn't need to execute pci_dev_put(). mci should still be freed, though, to prevent a memory leak. When pci_enable_device() fails, the error injection PCI device "einj" doesn't need to be disabled either. [ bp: Massage commit message, rename label to "bail_mc_free". ] Fixes: 52608ba ("i5100_edac: probe for device 19 function 0") Signed-off-by: Dinghao Liu <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent b5fb513 commit 857a313

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/edac/i5100_edac.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,16 +1061,15 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
10611061
PCI_DEVICE_ID_INTEL_5100_19, 0);
10621062
if (!einj) {
10631063
ret = -ENODEV;
1064-
goto bail_einj;
1064+
goto bail_mc_free;
10651065
}
10661066

10671067
rc = pci_enable_device(einj);
10681068
if (rc < 0) {
10691069
ret = rc;
1070-
goto bail_disable_einj;
1070+
goto bail_einj;
10711071
}
10721072

1073-
10741073
mci->pdev = &pdev->dev;
10751074

10761075
priv = mci->pvt_info;
@@ -1136,14 +1135,14 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
11361135
bail_scrub:
11371136
priv->scrub_enable = 0;
11381137
cancel_delayed_work_sync(&(priv->i5100_scrubbing));
1139-
edac_mc_free(mci);
1140-
1141-
bail_disable_einj:
11421138
pci_disable_device(einj);
11431139

11441140
bail_einj:
11451141
pci_dev_put(einj);
11461142

1143+
bail_mc_free:
1144+
edac_mc_free(mci);
1145+
11471146
bail_disable_ch1:
11481147
pci_disable_device(ch1mm);
11491148

0 commit comments

Comments
 (0)