From: Yige Jiang <yigejiang86@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Yige Jiang <yigejiang86@gmail.com>,
vigneshr@ti.com, tudor.ambarus@linaro.org,
miquel.raynal@bootlin.com, richard@nod.at,
linux-kernel@vger.kernel.org, geert+renesas@glider.be,
linux-renesas-soc@vger.kernel.org
Subject: [PATCH v2] mtd: hyperbus: rpc-if: fix an OF node reference leak
Date: Fri, 30 Oct 2026 02:11:13 +0800 [thread overview]
Message-ID: <20261029181114.78137-1-yigejiang86@gmail.com> (raw)
rpcif_hb_probe() gets a child-node reference with of_get_next_child().
The HyperBus core does not consume it, so the driver leaks the
reference on registration failure and remove.
Put the node on registration failure and after unregistering the
HyperBus device on remove. Leave hardware initialization failures on
out_disable_rpm, since no node reference has been acquired there.
Fixes: 5de15b610f78 ("mtd: hyperbus: add Renesas RPC-IF driver")
Assisted-by: LLM
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Changes in v2:
- Move of_node_put() before pm_runtime_disable() in the remove path
to match the probe error path, as suggested by Miquel Raynal.
v1: https://patchwork.ozlabs.org/project/linux-mtd/patch/rc-review-20261023-ai33-33-fd231771d138@gmail.com/
Based on linux-next next-20261016 (2efb7a11f1aa).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
CONFIG_COMPILE_TEST=y.
The object was rebuilt from this exact base with v2 applied.
No full kernel or module-link, hardware or runtime test was performed.
drivers/mtd/hyperbus/rpc-if.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/hyperbus/rpc-if.c b/drivers/mtd/hyperbus/rpc-if.c
index f448e23f9260f10abe17842849b312365dcd8294..ffa6578b5d399d19d3cac27d7769cccfceb0be92 100644
--- a/drivers/mtd/hyperbus/rpc-if.c
+++ b/drivers/mtd/hyperbus/rpc-if.c
@@ -145,10 +145,12 @@ static int rpcif_hb_probe(struct platform_device *pdev)
hyperbus->hbdev.np = of_get_next_child(pdev->dev.parent->of_node, NULL);
error = hyperbus_register_device(&hyperbus->hbdev);
if (error)
- goto out_disable_rpm;
+ goto out_put_node;
return 0;
+out_put_node:
+ of_node_put(hyperbus->hbdev.np);
out_disable_rpm:
pm_runtime_disable(hyperbus->rpc.dev);
return error;
@@ -159,6 +161,7 @@ static void rpcif_hb_remove(struct platform_device *pdev)
struct rpcif_hyperbus *hyperbus = platform_get_drvdata(pdev);
hyperbus_unregister_device(&hyperbus->hbdev);
+ of_node_put(hyperbus->hbdev.np);
pm_runtime_disable(hyperbus->rpc.dev);
}
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
--
2.50.1 (Apple Git-155)
WARNING: multiple messages have this Message-ID (diff)
From: Yige Jiang <yigejiang86@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Yige Jiang <yigejiang86@gmail.com>,
vigneshr@ti.com, tudor.ambarus@linaro.org,
miquel.raynal@bootlin.com, richard@nod.at,
linux-kernel@vger.kernel.org, geert+renesas@glider.be,
linux-renesas-soc@vger.kernel.org
Subject: [PATCH v2] mtd: hyperbus: rpc-if: fix an OF node reference leak
Date: Fri, 30 Oct 2026 02:11:13 +0800 [thread overview]
Message-ID: <20261029181114.78137-1-yigejiang86@gmail.com> (raw)
rpcif_hb_probe() gets a child-node reference with of_get_next_child().
The HyperBus core does not consume it, so the driver leaks the
reference on registration failure and remove.
Put the node on registration failure and after unregistering the
HyperBus device on remove. Leave hardware initialization failures on
out_disable_rpm, since no node reference has been acquired there.
Fixes: 5de15b610f78 ("mtd: hyperbus: add Renesas RPC-IF driver")
Assisted-by: LLM
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Changes in v2:
- Move of_node_put() before pm_runtime_disable() in the remove path
to match the probe error path, as suggested by Miquel Raynal.
v1: https://patchwork.ozlabs.org/project/linux-mtd/patch/rc-review-20261023-ai33-33-fd231771d138@gmail.com/
Based on linux-next next-20261016 (2efb7a11f1aa).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
CONFIG_COMPILE_TEST=y.
The object was rebuilt from this exact base with v2 applied.
No full kernel or module-link, hardware or runtime test was performed.
drivers/mtd/hyperbus/rpc-if.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/hyperbus/rpc-if.c b/drivers/mtd/hyperbus/rpc-if.c
index f448e23f9260f10abe17842849b312365dcd8294..ffa6578b5d399d19d3cac27d7769cccfceb0be92 100644
--- a/drivers/mtd/hyperbus/rpc-if.c
+++ b/drivers/mtd/hyperbus/rpc-if.c
@@ -145,10 +145,12 @@ static int rpcif_hb_probe(struct platform_device *pdev)
hyperbus->hbdev.np = of_get_next_child(pdev->dev.parent->of_node, NULL);
error = hyperbus_register_device(&hyperbus->hbdev);
if (error)
- goto out_disable_rpm;
+ goto out_put_node;
return 0;
+out_put_node:
+ of_node_put(hyperbus->hbdev.np);
out_disable_rpm:
pm_runtime_disable(hyperbus->rpc.dev);
return error;
@@ -159,6 +161,7 @@ static void rpcif_hb_remove(struct platform_device *pdev)
struct rpcif_hyperbus *hyperbus = platform_get_drvdata(pdev);
hyperbus_unregister_device(&hyperbus->hbdev);
+ of_node_put(hyperbus->hbdev.np);
pm_runtime_disable(hyperbus->rpc.dev);
}
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
--
2.50.1 (Apple Git-155)
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2026-10-29 18:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 18:11 Yige Jiang [this message]
2026-10-29 18:11 ` [PATCH v2] mtd: hyperbus: rpc-if: fix an OF node reference leak Yige Jiang
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=20261029181114.78137-1-yigejiang86@gmail.com \
--to=yigejiang86@gmail.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.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 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.