[PATCH] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup

Rounak Das posted 1 patch 1 week ago
There is a newer version of this series
drivers/edac/altera_edac.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
[PATCH] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup
Posted by Rounak Das 1 week ago
Under altr_portb_setup() and socfpga_init_sdmmc_ecc(),
of_find_compatible_node() was being used to look up the sdmmc-ecc
node. This node wasn't being dropped using of_node_put().

altr_portb_setup() did not drop its reference under its success path
or on any error path.

socfpga_int_sdmmc_ecc() did an early return thereby skipping the
common exit label and thus leaking the reference.

Add the missing of_node_put() calls in altr_portb_setup(), and route
socfpga_init_sdmmc_ecc()'s success path through the common exit label.

Signed-off-by: Rounak Das <rounakdas2025@gmail.com>
---
 drivers/edac/altera_edac.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 68846f583eee..777ba6efcc54 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -1524,6 +1524,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	dci = edac_device_alloc_ctl_info(sizeof(*altdev), ecc_name, 1,
 					 ecc_name, 1, 0, edac_idx);
 	if (!dci) {
+		of_node_put(np);
 		edac_printk(KERN_ERR, EDAC_DEVICE,
 			    "%s: Unable to allocate PortB EDAC device\n",
 			    ecc_name);
@@ -1534,8 +1535,10 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	altdev = dci->pvt_info;
 	*altdev = *device;
 
-	if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL))
+	if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) {
+		of_node_put(np);
 		return -ENOMEM;
+	}
 
 	/* Update PortB specific values */
 	altdev->edac_dev_name = ecc_name;
@@ -1600,6 +1603,8 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 		rc = -ENOMEM;
 		goto err_release_group_1;
 	}
+	of_node_put(np);
+
 	altr_create_edacdev_dbgfs(dci, prv);
 
 	list_add(&altdev->next, &altdev->edac->a10_ecc_devices);
@@ -1609,6 +1614,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	return 0;
 
 err_release_group_1:
+	of_node_put(np);
 	edac_device_free_ctl_info(dci);
 	devres_release_group(device->edac->dev, altr_portb_setup);
 	edac_printk(KERN_ERR, EDAC_DEVICE,
@@ -1638,7 +1644,7 @@ static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device)
 		goto exit;
 
 	/* Setup portB */
-	return altr_portb_setup(device);
+	rc = altr_portb_setup(device);
 
 exit:
 	of_node_put(child);
-- 
2.50.1 (Apple Git-155)
Re: [PATCH] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup
Posted by Dinh Nguyen 1 week ago

On 7/17/26 05:25, Rounak Das wrote:
> Under altr_portb_setup() and socfpga_init_sdmmc_ecc(),
> of_find_compatible_node() was being used to look up the sdmmc-ecc
> node. This node wasn't being dropped using of_node_put().
> 
> altr_portb_setup() did not drop its reference under its success path
> or on any error path.
> 
> socfpga_int_sdmmc_ecc() did an early return thereby skipping the
> common exit label and thus leaking the reference.
> 
> Add the missing of_node_put() calls in altr_portb_setup(), and route
> socfpga_init_sdmmc_ecc()'s success path through the common exit label.
> 
> Signed-off-by: Rounak Das <rounakdas2025@gmail.com>
> ---
>   drivers/edac/altera_edac.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 

If this patch is fixing an issued, please add the Fixes tag and also a 
Cc: stable@vger.kernel.org. For reference you can look at
Documentation/process/stable-kernel-rules.rst . Also, if you are 
addressing a sashiko review, add a Closes tag as well. Please see [0] as 
an example.

Thanks,
Dinh

[0] https://lore.kernel.org/all/20260617164303.585555-1-dinguyen@kernel.org/
[PATCH v2] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup
Posted by Rounak Das 1 week ago
Under altr_portb_setup() and socfpga_init_sdmmc_ecc(),
of_find_compatible_node() was being used to look up the sdmmc-ecc
node. This node wasn't being dropped using of_node_put().

altr_portb_setup() did not drop its reference under its success path
or on any error path.

socfpga_init_sdmmc_ecc() did an early return thereby skipping the
common exit label and thus leaking the reference.

Add the missing of_node_put() calls in altr_portb_setup(), and route
socfpga_init_sdmmc_ecc()'s success path through the common exit label.

Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
Fixes: 788586efd116 ("EDAC/altera: Initialize peripheral FIFOs in probe()")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/20260708091135.94114-1-rounakdas2025%40gmail.com
Signed-off-by: Rounak Das <rounakdas2025@gmail.com>
---
v2:
 - Add Fixes:, Cc: stable, and Closes: tags (Dinh).

v1: https://lore.kernel.org/all/20260717102549.13309-1-rounakdas2025@gmail.com/
---
 drivers/edac/altera_edac.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 68846f583eee..777ba6efcc54 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -1524,6 +1524,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	dci = edac_device_alloc_ctl_info(sizeof(*altdev), ecc_name, 1,
 					 ecc_name, 1, 0, edac_idx);
 	if (!dci) {
+		of_node_put(np);
 		edac_printk(KERN_ERR, EDAC_DEVICE,
 			    "%s: Unable to allocate PortB EDAC device\n",
 			    ecc_name);
@@ -1534,8 +1535,10 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	altdev = dci->pvt_info;
 	*altdev = *device;
 
-	if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL))
+	if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) {
+		of_node_put(np);
 		return -ENOMEM;
+	}
 
 	/* Update PortB specific values */
 	altdev->edac_dev_name = ecc_name;
@@ -1600,6 +1603,8 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 		rc = -ENOMEM;
 		goto err_release_group_1;
 	}
+	of_node_put(np);
+
 	altr_create_edacdev_dbgfs(dci, prv);
 
 	list_add(&altdev->next, &altdev->edac->a10_ecc_devices);
@@ -1609,6 +1614,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
 	return 0;
 
 err_release_group_1:
+	of_node_put(np);
 	edac_device_free_ctl_info(dci);
 	devres_release_group(device->edac->dev, altr_portb_setup);
 	edac_printk(KERN_ERR, EDAC_DEVICE,
@@ -1638,7 +1644,7 @@ static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device)
 		goto exit;
 
 	/* Setup portB */
-	return altr_portb_setup(device);
+	rc = altr_portb_setup(device);
 
 exit:
 	of_node_put(child);
-- 
2.50.1 (Apple Git-155)
Re: [PATCH v2] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup
Posted by Dinh Nguyen 4 days, 14 hours ago

On 7/17/26 08:17, Rounak Das wrote:
> Under altr_portb_setup() and socfpga_init_sdmmc_ecc(),
> of_find_compatible_node() was being used to look up the sdmmc-ecc
> node. This node wasn't being dropped using of_node_put().
> 
> altr_portb_setup() did not drop its reference under its success path
> or on any error path.
> 
> socfpga_init_sdmmc_ecc() did an early return thereby skipping the
> common exit label and thus leaking the reference.
> 
> Add the missing of_node_put() calls in altr_portb_setup(), and route
> socfpga_init_sdmmc_ecc()'s success path through the common exit label.
> 
> Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
> Fixes: 788586efd116 ("EDAC/altera: Initialize peripheral FIFOs in probe()")
> Cc: stable@vger.kernel.org
> Closes: https://sashiko.dev/#/patchset/20260708091135.94114-1-rounakdas2025%40gmail.com
> Signed-off-by: Rounak Das <rounakdas2025@gmail.com>
> ---

Acked-by: Dinh Nguyen <dinguyen@kernel.org>
Re: [PATCH v2] EDAC/altera: Fix device node reference leaks in the SDMMC ECC setup
Posted by Borislav Petkov 4 days, 12 hours ago
On Mon, Jul 20, 2026 at 09:13:25AM -0500, Dinh Nguyen wrote:
> > Under altr_portb_setup() and socfpga_init_sdmmc_ecc(),
> > of_find_compatible_node() was being used to look up the sdmmc-ecc
> > node. This node wasn't being dropped using of_node_put().
> > 
> > altr_portb_setup() did not drop its reference under its success path
> > or on any error path.
> > 
> > socfpga_init_sdmmc_ecc() did an early return thereby skipping the
> > common exit label and thus leaking the reference.
> > 
> > Add the missing of_node_put() calls in altr_portb_setup(), and route
> > socfpga_init_sdmmc_ecc()'s success path through the common exit label.
> > 
> > Fixes: 911049845d70 ("EDAC, altera: Add Arria10 SD-MMC EDAC support")
> > Fixes: 788586efd116 ("EDAC/altera: Initialize peripheral FIFOs in probe()")
> > Cc: stable@vger.kernel.org
> > Closes: https://sashiko.dev/#/patchset/20260708091135.94114-1-rounakdas2025%40gmail.com
> > Signed-off-by: Rounak Das <rounakdas2025@gmail.com>
> > ---
> 
> Acked-by: Dinh Nguyen <dinguyen@kernel.org>

I'll hold off on that until the Sashiko preexisting issues have been
addressed:

https://sashiko.dev/#/patchset/20260717102549.13309-1-rounakdas2025%40gmail.com

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette