RE: [PATCH] EDAC/ie31200: Fix error handling in ie31200_register_mci

From: Zhuo, Qiuxu
Date: Tue Nov 04 2025 - 08:08:38 EST


Hi Ma Ke,

Thanks for this report.

> From: Ma Ke <make24@xxxxxxxxxxx>
> Sent: Tuesday, November 4, 2025 9:23 AM
> To: jbaron@xxxxxxxxxx; bp@xxxxxxxxx; Luck, Tony <tony.luck@xxxxxxxxx>;
> Zhuo, Qiuxu <qiuxu.zhuo@xxxxxxxxx>
> Cc: linux-edac@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; akpm@linux-
> foundation.org; Ma Ke <make24@xxxxxxxxxxx>; stable@xxxxxxxxxxxxxxx
> Subject: [PATCH] EDAC/ie31200: Fix error handling in ie31200_register_mci
>
> When mc > 0, ie31200_register_mci() initializes priv->dev but fails to call
> put_device() on it in the error path, causing a memory leak. Add proper

edac_mc_free() triggers mci_release(), which eventually frees mci->pvt_info,
so there are no memory leaks, and put_device() is NOT needed.

> put_device() call for priv->dev in the error handling path to balance
> device_initialize().
>

>From the perspective of pairing with device_initialize() for better code readability,
then we may add put_device().

> Found by code review.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: d0742284ec6d ("EDAC/ie31200: Add Intel Raptor Lake-S SoCs support")

This is not a real bug.
No "Fixes" tag needed to avoid unnecessary backporting.

> Signed-off-by: Ma Ke <make24@xxxxxxxxxxx>
> ---
> 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..a5a4bb24b72a 100644
> --- a/drivers/edac/ie31200_edac.c
> +++ b/drivers/edac/ie31200_edac.c
> @@ -528,6 +528,8 @@ static int ie31200_register_mci(struct pci_dev *pdev,
> struct res_config *cfg, in
> fail_unmap:
> iounmap(window);
> fail_free:
> + if (mc > 0)

Since both primary and secondary memory controllers invoke device_initialize(),
please remove this "if (mc > 0)" check to call put_device() unconditionally here.

> + put_device(&priv->dev);
> edac_mc_free(mci);
> return ret;
> }

Could you please address the comments above, update the commit messages,
and send v2?

Thanks!
-Qiuxu