mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dinh Nguyen <dinguyen@kernel.org>
To: bp@alien8.de, tony.luck@intel.com
Cc: dinguyen@kernel.org, rounakdas2025@gmail.com,
	niravkumar.l.rabara@altera.com, linux-edac@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 10/10] EDAC/altera: Fix error cleanup path in altr_edac_device_probe()
Date: Mon, 27 Jul 2026 08:24:16 -0500	[thread overview]
Message-ID: <20260727132416.807230-11-dinguyen@kernel.org> (raw)
In-Reply-To: <20260727132416.807230-1-dinguyen@kernel.org>

sashiko reports: Does the error cleanup path in
altr_edac_device_probe() free data before unregistering the interrupt
handler? If a failure occurs, dci is explicitly freed via
edac_device_free_ctl_info(dci) before the managed IRQ handler is unregistered
via devres_release_group(). If an interrupt fires in this window, could it
dereference the freed dci?

Clean up the fail1 path to always call devres_release_group() and
conditionally free the dci.

Fixes: c3eea1942a16 ("EDAC, altera: Add Altera L2 cache and OCRAM support")
Cc: stable@vger.kernel.org
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
 drivers/edac/altera_edac.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 80ca9f511ac98..b6048a1884f43 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -701,7 +701,7 @@ MODULE_DEVICE_TABLE(of, altr_edac_device_of_match);
  */
 static int altr_edac_device_probe(struct platform_device *pdev)
 {
-	struct edac_device_ctl_info *dci;
+	struct edac_device_ctl_info *dci = NULL;
 	struct altr_edac_device_dev *drvdata;
 	struct resource *r;
 	int res = 0;
@@ -729,7 +729,7 @@ static int altr_edac_device_probe(struct platform_device *pdev)
 		edac_printk(KERN_ERR, EDAC_DEVICE,
 			    "Unable to get mem resource\n");
 		res = -ENODEV;
-		goto fail;
+		goto fail1;
 	}
 
 	if (!devm_request_mem_region(&pdev->dev, r->start, resource_size(r),
@@ -737,7 +737,7 @@ static int altr_edac_device_probe(struct platform_device *pdev)
 		edac_printk(KERN_ERR, EDAC_DEVICE,
 			    "%s:Error requesting mem region\n", ecc_name);
 		res = -EBUSY;
-		goto fail;
+		goto fail1;
 	}
 
 	dci = edac_device_alloc_ctl_info(sizeof(*drvdata), ecc_name,
@@ -747,7 +747,7 @@ static int altr_edac_device_probe(struct platform_device *pdev)
 		edac_printk(KERN_ERR, EDAC_DEVICE,
 			    "%s: Unable to allocate EDAC device\n", ecc_name);
 		res = -ENOMEM;
-		goto fail;
+		goto fail1;
 	}
 
 	drvdata = dci->pvt_info;
@@ -806,9 +806,9 @@ static int altr_edac_device_probe(struct platform_device *pdev)
 	return 0;
 
 fail1:
-	edac_device_free_ctl_info(dci);
-fail:
 	devres_release_group(&pdev->dev, NULL);
+	if (dci)
+		edac_device_free_ctl_info(dci);
 	edac_printk(KERN_ERR, EDAC_DEVICE,
 		    "%s:Error setting up EDAC device: %d\n", ecc_name, res);
 
-- 
2.42.0.411.g813d9a9188


      parent reply	other threads:[~2026-07-27 13:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 13:24 [PATCH 00/10] EDAC/altera: Address sashiko reviews part 1 Dinh Nguyen
2026-07-27 13:24 ` [PATCH 01/10] EDAC/altera: Fix NULL of_node dereference altr_edac_device_probe() Dinh Nguyen
2026-07-28 18:56   ` Borislav Petkov
2026-07-31 13:49     ` Dinh Nguyen
2026-07-27 13:24 ` [PATCH 02/10] EDAC/altera: Fix use-after-free in error paths Dinh Nguyen
2026-07-27 13:24 ` [PATCH 03/10] EDAC/altera: Guard against NULL match data in altr_sdram_probe() Dinh Nguyen
2026-07-27 13:24 ` [PATCH 04/10] EDAC/altera: Fix IRQ domain leak on platform_get_irq() failure Dinh Nguyen
2026-07-27 13:24 ` [PATCH 05/10] EDAC/altera: Fix code leak on dci allocation failure Dinh Nguyen
2026-07-27 13:24 ` [PATCH 06/10] EDAC/altera: Add suppress_bind_attrs so driver cannot get unbound Dinh Nguyen
2026-07-27 13:24 ` [PATCH 07/10] EDAC/altera: Drop __init from ECC setup paths for re-probe safety Dinh Nguyen
2026-07-27 13:24 ` [PATCH 08/10] EDAC/altera: Skip ECC memory init if already initialized Dinh Nguyen
2026-07-27 13:24 ` [PATCH 09/10] EDAC/altera: Detach sb_irq handler when db_irq setup fails Dinh Nguyen
2026-07-27 13:24 ` Dinh Nguyen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260727132416.807230-11-dinguyen@kernel.org \
    --to=dinguyen@kernel.org \
    --cc=bp@alien8.de \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niravkumar.l.rabara@altera.com \
    --cc=rounakdas2025@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®