All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yige Jiang <yigejiang86@gmail.com>
To: Santosh Shilimkar <ssantosh@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
	linux-kernel@vger.kernel.org,
	Miles Krause <mileskrause5200@gmail.com>
Subject: [PATCH] memory: emif: Put the DDR node on probe failure
Date: Tue, 24 Nov 2026 01:38:28 +0800	[thread overview]
Message-ID: <confirmed-20261105-11-5d830ffabcd8@gmail.com> (raw)

of_get_memory_device_details() returns an emif_data holding a reference
to the DDR device node. Although the helper's failures and emif_remove()
now release that reference, emif_probe() still leaks it when mapping the
registers, obtaining the IRQ, or setting up the interrupts fails.

Route those three failures through an of_node_put() before returning.
Keep the existing path for failures to obtain the device details, which
have already handled their node reference. The non-DT path is safe too,
since its zero-initialized np_ddr remains NULL.

Fixes: e6b42eb6a66c ("memory: emif: add device tree support to emif driver")
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
AI assistance was used for analysis and patch preparation.

Based on next-20261104 (8b7179210b22).
Compile-tested: arm64, GCC 14.2.0, W=1, drivers/memory/emif.o;
baseline and patched objects built with no warnings.
Static source review; no hardware, boot, or KASAN test was performed.

 drivers/memory/emif.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index 886c2ca0dc19d4388feb6f8670aa6cd579e426b0..68b12528968fd1b8db310d51a008f6abdfd75718 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -1106,18 +1106,18 @@ static int emif_probe(struct platform_device *pdev)
 
 	emif->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(emif->base))
-		goto error;
+		goto put_node;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
-		goto error;
+		goto put_node;
 
 	emif_onetime_settings(emif);
 	emif_debugfs_init(emif);
 	disable_and_clear_all_interrupts(emif);
 	ret = setup_interrupts(emif, irq);
 	if (ret)
-		goto error;
+		goto put_node;
 
 	/* One-time actions taken on probing the first device */
 	if (!emif1) {
@@ -1134,6 +1134,8 @@ static int emif_probe(struct platform_device *pdev)
 		__func__, emif->base, irq);
 
 	return 0;
+put_node:
+	of_node_put(emif->np_ddr);
 error:
 	return -ENODEV;
 }

base-commit: 8b7179210b22f8e48a82c5ceacb9d56a9c4cfec4

                 reply	other threads:[~2026-11-23 17:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=confirmed-20261105-11-5d830ffabcd8@gmail.com \
    --to=yigejiang86@gmail.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mileskrause5200@gmail.com \
    --cc=ssantosh@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.