[PATCHv4 3/4] EDAC/altera: Fix code leak on dci allocation failure
From: Dinh Nguyen
Date: Wed Sep 09 2026 - 10:25:25 EST
sashiko reports: If devres_open_group() fails, the function returns -ENOMEM
without freeing the dci structure allocated earlier with edac_device_alloc_ctl_info().
Free the dci structure if devres_open_group() fails.
Fixes: c3eea1942a16 ("EDAC, altera: Add Altera L2 cache and OCRAM support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
---
v4: rebased to edac-urgent
v3: No changes
v2: reworked v1 to include only true sashiko hits
---
drivers/edac/altera_edac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index d8a3438fb5f44..4b289b90186f9 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -1517,7 +1517,9 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
*altdev = *device;
if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL))
+ edac_device_free_ctl_info(dci);
return -ENOMEM;
+ }
/* Update PortB specific values */
altdev->edac_dev_name = ecc_name;
--
2.42.0.411.g813d9a9188