]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
EDAC/ie31200: Fix error handling in ie31200_register_mci
authorMa Ke <make24@iscas.ac.cn>
Thu, 6 Nov 2025 08:47:35 +0000 (16:47 +0800)
committerTony Luck <tony.luck@intel.com>
Tue, 11 Nov 2025 01:06:10 +0000 (17:06 -0800)
ie31200_register_mci() calls device_initialize() for priv->dev
unconditionally. However, in the error path, put_device() is not
called, leading to an imbalance. Similarly, in the unload path,
put_device() is missing.

Although edac_mc_free() eventually frees the memory, it does not
release the device initialized by device_initialize(). For code
readability and proper pairing of device_initialize()/put_device(),
add put_device() calls in both error and unload paths.

Found by code review.

Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Link: https://patch.msgid.link/20251106084735.35017-1-make24@iscas.ac.cn
drivers/edac/ie31200_edac.c

index 5a080ab65476dacf263447b456c90b34fdac9a6c..8d4ddaa85ae82676bd8d30914f61bd8770be9896 100644 (file)
@@ -526,6 +526,7 @@ static int ie31200_register_mci(struct pci_dev *pdev, struct res_config *cfg, in
        ie31200_pvt.priv[mc] = priv;
        return 0;
 fail_unmap:
+       put_device(&priv->dev);
        iounmap(window);
 fail_free:
        edac_mc_free(mci);
@@ -598,6 +599,7 @@ static void ie31200_unregister_mcis(void)
                mci = priv->mci;
                edac_mc_del_mc(mci->pdev);
                iounmap(priv->window);
+               put_device(&priv->dev);
                edac_mc_free(mci);
        }
 }