* [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak
@ 2026-05-03 21:25 Yuho Choi
2026-05-04 13:12 ` Dinh Nguyen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yuho Choi @ 2026-05-03 21:25 UTC (permalink / raw)
To: Dinh Nguyen, Borislav Petkov, Tony Luck
Cc: linux-edac, linux-kernel, Yuho Choi
of_find_compatible_node() returns a device node with its refcount
incremented. altr_portb_setup() looks up the SDMMC ECC node but does
not drop that reference on error paths or after successful setup.
Route those exits through an of_node_put() cleanup path. Also free the
EDAC control info if devres_open_group() fails after dci has been
allocated, and release the devres group before freeing dci because
altdev is stored in dci->pvt_info.
Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
Changes since v1:
- Free the EDAC control info when devres_open_group() fails after dci
has been allocated.
- Release the PortB devres group before freeing dci so altdev->ddev
remains valid during devres cleanup.
- Keep the !dci failure path limited to dropping the OF node reference.
drivers/edac/altera_edac.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 4edd2088c2db..1b050e35ec4b 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -1526,15 +1526,18 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
edac_printk(KERN_ERR, EDAC_DEVICE,
"%s: Unable to allocate PortB EDAC device\n",
ecc_name);
- return -ENOMEM;
+ rc = -ENOMEM;
+ goto out_put_node;
}
/* Initialize the PortB EDAC device structure from PortA structure */
altdev = dci->pvt_info;
*altdev = *device;
- if (!devres_open_group(&altdev->ddev, altr_portb_setup, GFP_KERNEL))
- return -ENOMEM;
+ if (!devres_open_group(&altdev->ddev, altr_portb_setup, GFP_KERNEL)) {
+ rc = -ENOMEM;
+ goto err_free_ctl;
+ }
/* Update PortB specific values */
altdev->edac_dev_name = ecc_name;
@@ -1607,13 +1610,17 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
devres_remove_group(&altdev->ddev, altr_portb_setup);
- return 0;
+ rc = 0;
+ goto out_put_node;
err_release_group_1:
- edac_device_free_ctl_info(dci);
devres_release_group(&altdev->ddev, altr_portb_setup);
+err_free_ctl:
+ edac_device_free_ctl_info(dci);
edac_printk(KERN_ERR, EDAC_DEVICE,
"%s:Error setting up EDAC device: %d\n", ecc_name, rc);
+out_put_node:
+ of_node_put(np);
return rc;
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak
2026-05-03 21:25 [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak Yuho Choi
@ 2026-05-04 13:12 ` Dinh Nguyen
2026-05-05 3:29 ` Zhuo, Qiuxu
2026-06-01 13:47 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Dinh Nguyen @ 2026-05-04 13:12 UTC (permalink / raw)
To: Yuho Choi, Borislav Petkov, Tony Luck; +Cc: linux-edac, linux-kernel
On 5/3/26 16:25, Yuho Choi wrote:
> of_find_compatible_node() returns a device node with its refcount
> incremented. altr_portb_setup() looks up the SDMMC ECC node but does
> not drop that reference on error paths or after successful setup.
>
> Route those exits through an of_node_put() cleanup path. Also free the
> EDAC control info if devres_open_group() fails after dci has been
> allocated, and release the devres group before freeing dci because
> altdev is stored in dci->pvt_info.
>
> Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
I think you need the
Cc: stable@vger.kernel.org
But other than that:
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
Thanks,
Dinh
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak
2026-05-03 21:25 [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak Yuho Choi
2026-05-04 13:12 ` Dinh Nguyen
@ 2026-05-05 3:29 ` Zhuo, Qiuxu
2026-06-01 13:47 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Zhuo, Qiuxu @ 2026-05-05 3:29 UTC (permalink / raw)
To: Yuho Choi, Dinh Nguyen, Borislav Petkov, Luck, Tony
Cc: linux-edac, linux-kernel
> From: Yuho Choi <dbgh9129@gmail.com>
> Sent: Monday, May 4, 2026 5:26 AM
> To: Dinh Nguyen <dinguyen@kernel.org>; Borislav Petkov <bp@alien8.de>;
> Luck, Tony <tony.luck@intel.com>
> Cc: linux-edac@vger.kernel.org; linux-kernel@vger.kernel.org; Yuho Choi
> <dbgh9129@gmail.com>
> Subject: [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak
>
> of_find_compatible_node() returns a device node with its refcount
> incremented. altr_portb_setup() looks up the SDMMC ECC node but does not
> drop that reference on error paths or after successful setup.
>
> Route those exits through an of_node_put() cleanup path. Also free the EDAC
> control info if devres_open_group() fails after dci has been allocated, and
> release the devres group before freeing dci because altdev is stored in dci-
> >pvt_info.
>
> Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> Changes since v1:
> - Free the EDAC control info when devres_open_group() fails after dci
> has been allocated.
> - Release the PortB devres group before freeing dci so altdev->ddev
> remains valid during devres cleanup.
> - Keep the !dci failure path limited to dropping the OF node reference.
>
> drivers/edac/altera_edac.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
LGTM. Thanks.
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak
2026-05-03 21:25 [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak Yuho Choi
2026-05-04 13:12 ` Dinh Nguyen
2026-05-05 3:29 ` Zhuo, Qiuxu
@ 2026-06-01 13:47 ` Borislav Petkov
2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2026-06-01 13:47 UTC (permalink / raw)
To: Yuho Choi; +Cc: Dinh Nguyen, Tony Luck, linux-edac, linux-kernel
On Sun, May 03, 2026 at 05:25:58PM -0400, Yuho Choi wrote:
> of_find_compatible_node() returns a device node with its refcount
> incremented. altr_portb_setup() looks up the SDMMC ECC node but does
> not drop that reference on error paths or after successful setup.
>
> Route those exits through an of_node_put() cleanup path. Also free the
> EDAC control info if devres_open_group() fails after dci has been
> allocated, and release the devres group before freeing dci because
> altdev is stored in dci->pvt_info.
>
> Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> Changes since v1:
> - Free the EDAC control info when devres_open_group() fails after dci
> has been allocated.
> - Release the PortB devres group before freeing dci so altdev->ddev
> remains valid during devres cleanup.
> - Keep the !dci failure path limited to dropping the OF node reference.
https://sashiko.dev/#/patchset/20260503212558.2811480-1-dbgh9129%40gmail.com
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-01 13:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-03 21:25 [PATCH v2] EDAC/altera: Fix SDMMC PortB OF node reference leak Yuho Choi
2026-05-04 13:12 ` Dinh Nguyen
2026-05-05 3:29 ` Zhuo, Qiuxu
2026-06-01 13:47 ` Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®