Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 52608ba205461 ("i5100_edac: probe for device 19 function 0")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200826121437.31606-1-dinghao.liu@zju.edu.cn

authored by

Dinghao Liu and committed by
Borislav Petkov
857a3139 b5fb5134

+5 -6
+5 -6
drivers/edac/i5100_edac.c
··· 1061 1061 PCI_DEVICE_ID_INTEL_5100_19, 0); 1062 1062 if (!einj) { 1063 1063 ret = -ENODEV; 1064 - goto bail_einj; 1064 + goto bail_mc_free; 1065 1065 } 1066 1066 1067 1067 rc = pci_enable_device(einj); 1068 1068 if (rc < 0) { 1069 1069 ret = rc; 1070 - goto bail_disable_einj; 1070 + goto bail_einj; 1071 1071 } 1072 - 1073 1072 1074 1073 mci->pdev = &pdev->dev; 1075 1074 ··· 1135 1136 bail_scrub: 1136 1137 priv->scrub_enable = 0; 1137 1138 cancel_delayed_work_sync(&(priv->i5100_scrubbing)); 1138 - edac_mc_free(mci); 1139 - 1140 - bail_disable_einj: 1141 1139 pci_disable_device(einj); 1142 1140 1143 1141 bail_einj: 1144 1142 pci_dev_put(einj); 1143 + 1144 + bail_mc_free: 1145 + edac_mc_free(mci); 1145 1146 1146 1147 bail_disable_ch1: 1147 1148 pci_disable_device(ch1mm);