drivers/firmware/arm_scpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
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 <gu_0233@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..6bf999a6ccf5 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/clean.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: d08c85ac8894995d4b0d8fb48d2f6a3e53cd79ab
change-id: 20260120-arm_scpi_of_node-ca97b68d7cf9
Best regards,
--
Felix Gu <gu_0233@qq.com>
Hi Felix,
kernel test robot noticed the following build errors:
[auto build test ERROR on d08c85ac8894995d4b0d8fb48d2f6a3e53cd79ab]
url: https://github.com/intel-lab-lkp/linux/commits/Felix-Gu/firmware-arm_scpi-Fix-device_node-reference-leak-in-scpi_probe/20260120-203159
base: d08c85ac8894995d4b0d8fb48d2f6a3e53cd79ab
patch link: https://lore.kernel.org/r/tencent_845B889AF1A932F1347EE0C09F350E491009%40qq.com
patch subject: [PATCH] firmware: arm_scpi: Fix device_node reference leak in scpi_probe()
config: riscv-randconfig-r064-20260121 (https://download.01.org/0day-ci/archive/20260121/202601210817.qdAqWG2J-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 14.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260121/202601210817.qdAqWG2J-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601210817.qdAqWG2J-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/firmware/arm_scpi.c:21:10: fatal error: linux/clean.h: No such file or directory
21 | #include <linux/clean.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
vim +21 drivers/firmware/arm_scpi.c
18
19 #include <linux/bitmap.h>
20 #include <linux/bitfield.h>
> 21 #include <linux/clean.h>
22 #include <linux/device.h>
23 #include <linux/err.h>
24 #include <linux/export.h>
25 #include <linux/io.h>
26 #include <linux/kernel.h>
27 #include <linux/list.h>
28 #include <linux/mailbox_client.h>
29 #include <linux/module.h>
30 #include <linux/of.h>
31 #include <linux/of_address.h>
32 #include <linux/of_platform.h>
33 #include <linux/platform_device.h>
34 #include <linux/printk.h>
35 #include <linux/property.h>
36 #include <linux/pm_opp.h>
37 #include <linux/scpi_protocol.h>
38 #include <linux/slab.h>
39 #include <linux/sort.h>
40 #include <linux/spinlock.h>
41
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Felix,
kernel test robot noticed the following build errors:
[auto build test ERROR on d08c85ac8894995d4b0d8fb48d2f6a3e53cd79ab]
url: https://github.com/intel-lab-lkp/linux/commits/Felix-Gu/firmware-arm_scpi-Fix-device_node-reference-leak-in-scpi_probe/20260120-203159
base: d08c85ac8894995d4b0d8fb48d2f6a3e53cd79ab
patch link: https://lore.kernel.org/r/tencent_845B889AF1A932F1347EE0C09F350E491009%40qq.com
patch subject: [PATCH] firmware: arm_scpi: Fix device_node reference leak in scpi_probe()
config: arm-randconfig-001-20260121 (https://download.01.org/0day-ci/archive/20260121/202601210508.3BaBN2n8-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260121/202601210508.3BaBN2n8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601210508.3BaBN2n8-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/firmware/arm_scpi.c:21:10: fatal error: 'linux/clean.h' file not found
21 | #include <linux/clean.h>
| ^~~~~~~~~~~~~~~
1 error generated.
vim +21 drivers/firmware/arm_scpi.c
18
19 #include <linux/bitmap.h>
20 #include <linux/bitfield.h>
> 21 #include <linux/clean.h>
22 #include <linux/device.h>
23 #include <linux/err.h>
24 #include <linux/export.h>
25 #include <linux/io.h>
26 #include <linux/kernel.h>
27 #include <linux/list.h>
28 #include <linux/mailbox_client.h>
29 #include <linux/module.h>
30 #include <linux/of.h>
31 #include <linux/of_address.h>
32 #include <linux/of_platform.h>
33 #include <linux/platform_device.h>
34 #include <linux/printk.h>
35 #include <linux/property.h>
36 #include <linux/pm_opp.h>
37 #include <linux/scpi_protocol.h>
38 #include <linux/slab.h>
39 #include <linux/sort.h>
40 #include <linux/spinlock.h>
41
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.