drivers/edac/ie31200_edac.c | 2 ++ 1 file changed, 2 insertions(+)
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>
---
Changes in v2:
- modified the patch, thanks for developer's suggestions;
- removed Fixes line.
---
drivers/edac/ie31200_edac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c
index 5a080ab65476..ea8fc0d5f347 100644
--- a/drivers/edac/ie31200_edac.c
+++ b/drivers/edac/ie31200_edac.c
@@ -528,6 +528,7 @@ static int ie31200_register_mci(struct pci_dev *pdev, struct res_config *cfg, in
fail_unmap:
iounmap(window);
fail_free:
+ put_device(&priv->dev);
edac_mc_free(mci);
return ret;
}
@@ -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);
}
}
--
2.17.1
> From: Ma Ke <make24@iscas.ac.cn> > Sent: Wednesday, November 5, 2025 10:22 AM > To: jbaron@akamai.com; bp@alien8.de; Luck, Tony <tony.luck@intel.com>; > Zhuo, Qiuxu <qiuxu.zhuo@intel.com> > Cc: linux-edac@vger.kernel.org; linux-kernel@vger.kernel.org; akpm@linux- > foundation.org; Ma Ke <make24@iscas.ac.cn> > Subject: [PATCH v2] EDAC/ie31200: Fix error handling in ie31200_register_mci > > 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> LGTM, thanks. Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
>> Found by code review. >> >> Signed-off-by: Ma Ke <make24@iscas.ac.cn> > > LGTM, thanks. > > Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Applied to RAS tree edac-drivers branch. Thanks -Tony
© 2016 - 2025 Red Hat, Inc.