Skip to content

Commit

Permalink
EDAC/i5100: Fix error handling order in i5100_init_one()
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
dinghaoliu authored and suryasaimadhu committed Sep 1, 2020
1 parent b5fb513 commit 857a313
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/edac/i5100_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,16 +1061,15 @@ 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_mc_free;
}

rc = pci_enable_device(einj);
if (rc < 0) {
ret = rc;
goto bail_disable_einj;
goto bail_einj;
}


mci->pdev = &pdev->dev;

priv = mci->pvt_info;
Expand Down Expand Up @@ -1136,14 +1135,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_mc_free:
edac_mc_free(mci);

bail_disable_ch1:
pci_disable_device(ch1mm);

Expand Down

0 comments on commit 857a313

Please sign in to comment.