mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] firmware: arm_scpi: Fix device_node reference leak in scpi_probe()
@ 2026-01-21 13:08 Felix Gu
  2026-03-08 12:57 ` Sudeep Holla
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-01-21 13:08 UTC (permalink / raw)
  To: Sudeep Holla, Cristian Marussi
  Cc: arm-scmi, linux-arm-kernel, linux-kernel, Felix Gu

In scpi_probe(), if of_match_node() fails and the function returns
early, the shmem reference is not released.
Use __free(device_node) scope-based cleanup to automatically release
the reference when the variable goes out of scope.

Fixes: ed7ecb883901 ("firmware: arm_scpi: Add compatibility checks for shmem node")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Fixed build failure reported by kernel test robot.
- Link to v1: https://lore.kernel.org/arm-scmi/tencent_845B889AF1A932F1347EE0C09F350E491009@qq.com/
---
 drivers/firmware/arm_scpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 87c323de17b9..398642cc25d9 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -18,6 +18,7 @@
 
 #include <linux/bitmap.h>
 #include <linux/bitfield.h>
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/export.h>
@@ -940,13 +941,13 @@ static int scpi_probe(struct platform_device *pdev)
 		int idx = scpi_drvinfo->num_chans;
 		struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
 		struct mbox_client *cl = &pchan->cl;
-		struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
+		struct device_node *shmem __free(device_node) =
+			of_parse_phandle(np, "shmem", idx);
 
 		if (!of_match_node(shmem_of_match, shmem))
 			return -ENXIO;
 
 		ret = of_address_to_resource(shmem, 0, &res);
-		of_node_put(shmem);
 		if (ret) {
 			dev_err(dev, "failed to get SCPI payload mem resource\n");
 			return ret;

---
base-commit: 053966c344dbd346e71305f530e91ea77916189f
change-id: 20260121-arm_scpi_2-44e00b03f456

Best regards,
-- 
Felix Gu <ustc.gu@gmail.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] firmware: arm_scpi: Fix device_node reference leak in scpi_probe()
  2026-01-21 13:08 [PATCH v2] firmware: arm_scpi: Fix device_node reference leak in scpi_probe() Felix Gu
@ 2026-03-08 12:57 ` Sudeep Holla
  0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2026-03-08 12:57 UTC (permalink / raw)
  To: Cristian Marussi, Sudeep Holla, Felix Gu
  Cc: arm-scmi, linux-arm-kernel, linux-kernel

On Wed, 21 Jan 2026 21:08:19 +0800, Felix Gu wrote:
> In scpi_probe(), if of_match_node() fails and the function returns
> early, the shmem reference is not released.
> Use __free(device_node) scope-based cleanup to automatically release
> the reference when the variable goes out of scope.
> 
> 

Applied to sudeep.holla/linux (for-next/scmi/fixes), thanks!


[1/1] firmware: arm_scpi: Fix device_node reference leak in scpi_probe()
      https://git.kernel.org/sudeep.holla/c/879c001afbac

--
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-08 12:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21 13:08 [PATCH v2] firmware: arm_scpi: Fix device_node reference leak in scpi_probe() Felix Gu
2026-03-08 12:57 ` Sudeep Holla

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®