* [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci
@ 2025-11-06 8:47 Ma Ke
2025-11-06 11:34 ` Borislav Petkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ma Ke @ 2025-11-06 8:47 UTC (permalink / raw)
To: jbaron, bp, tony.luck, qiuxu.zhuo; +Cc: linux-edac, linux-kernel, akpm, Ma Ke
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 v3:
- moved put_device() from fail_free to fail_unmap to avoid using uninitialized priv variable when window allocation fails.
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..8d4ddaa85ae8 100644
--- a/drivers/edac/ie31200_edac.c
+++ b/drivers/edac/ie31200_edac.c
@@ -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);
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci
2025-11-06 8:47 [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci Ma Ke
@ 2025-11-06 11:34 ` Borislav Petkov
2025-11-06 13:07 ` Zhuo, Qiuxu
2025-11-11 1:15 ` Luck, Tony
2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2025-11-06 11:34 UTC (permalink / raw)
To: tony.luck; +Cc: Ma Ke, jbaron, qiuxu.zhuo, linux-edac, linux-kernel, akpm
On Thu, Nov 06, 2025 at 04:47:35PM +0800, Ma Ke wrote:
> 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 v3:
> - moved put_device() from fail_free to fail_unmap to avoid using uninitialized priv variable when window allocation fails.
Zapped v2 from the tree for the time being.
> Changes in v2:
> - modified the patch, thanks for developer's suggestions;
> - removed Fixes line.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci
2025-11-06 8:47 [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci Ma Ke
2025-11-06 11:34 ` Borislav Petkov
@ 2025-11-06 13:07 ` Zhuo, Qiuxu
2025-11-11 1:15 ` Luck, Tony
2 siblings, 0 replies; 4+ messages in thread
From: Zhuo, Qiuxu @ 2025-11-06 13:07 UTC (permalink / raw)
To: Ma Ke, jbaron@akamai.com, bp@alien8.de, Luck, Tony
Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org
> From: Ma Ke <make24@iscas.ac.cn>
> Sent: Thursday, November 6, 2025 4:48 PM
> 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 v3] 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>
> ---
> Changes in v3:
> - moved put_device() from fail_free to fail_unmap to avoid using uninitialized
> priv variable when window allocation fails.
Oops ... I didn't catch that during v2 review.
For v3:
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> [...]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci
2025-11-06 8:47 [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci Ma Ke
2025-11-06 11:34 ` Borislav Petkov
2025-11-06 13:07 ` Zhuo, Qiuxu
@ 2025-11-11 1:15 ` Luck, Tony
2 siblings, 0 replies; 4+ messages in thread
From: Luck, Tony @ 2025-11-11 1:15 UTC (permalink / raw)
To: Ma Ke; +Cc: jbaron, bp, qiuxu.zhuo, linux-edac, linux-kernel, akpm
On Thu, Nov 06, 2025 at 04:47:35PM +0800, Ma Ke wrote:
> 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>
Applied v3 version.
Thanks
-Tony
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-11 1:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 8:47 [PATCH v3] EDAC/ie31200: Fix error handling in ie31200_register_mci Ma Ke
2025-11-06 11:34 ` Borislav Petkov
2025-11-06 13:07 ` Zhuo, Qiuxu
2025-11-11 1:15 ` Luck, Tony
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox