All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch: fix resource leak in chmc.c
@ 2025-07-18  9:22 Jacky Liu
  2025-07-18 13:25 ` Krzysztof Kozlowski
  2025-07-18 13:43 ` [PATCH] " Markus Elfring
  0 siblings, 2 replies; 11+ messages in thread
From: Jacky Liu @ 2025-07-18  9:22 UTC (permalink / raw)
  To: davem; +Cc: andreas, 1972843537, sparclinux, linux-kernel

From: Siyang Liu <1972843537@qq.com>

In the jbusmc_probe function, the device node mem_node fetched 
via of_find_node_by_path("/memory") is not properly freed 
on all code paths. 
This can lead to leakage of device node reference counts, 
which may result in kernel resources not being released.

This issue was detected by rule based static tools 
developed by Tencent.

Signed-off-by: Siyang Liu <1972843537@qq.com>
---
 arch/sparc/kernel/chmc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c
index d4c74d6b2e1b..a7040ee7e5bc 100644
--- a/arch/sparc/kernel/chmc.c
+++ b/arch/sparc/kernel/chmc.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2001, 2007, 2008 David S. Miller (davem@davemloft.net)
  */
 
+#include <linux/cleanup.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -397,14 +398,14 @@ static void jbusmc_construct_dimm_groups(struct jbusmc *p,
 static int jbusmc_probe(struct platform_device *op)
 {
 	const struct linux_prom64_registers *mem_regs;
-	struct device_node *mem_node;
+	struct device_node *mem_node __free(device_node) =
+			of_find_node_by_path("/memory");
 	int err, len, num_mem_regs;
 	struct jbusmc *p;
 	const u32 *prop;
 	const void *ml;
 
 	err = -ENODEV;
-	mem_node = of_find_node_by_path("/memory");
 	if (!mem_node) {
 		printk(KERN_ERR PFX "Cannot find /memory node.\n");
 		goto out;
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] dm-raid: do not include dm-core.h
@ 2025-07-21  3:49 Pavel Tikhomirov
  2025-07-21  3:56 ` [PATCH v2] arch: fix resource leak in jbusmc_probe() jackysliu
  0 siblings, 1 reply; 11+ messages in thread
From: Pavel Tikhomirov @ 2025-07-21  3:49 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka
  Cc: Xiao Ni, Yu Kuai, dm-devel, linux-kernel, Konstantin Khorenko,
	Denis Lunev

In commit 4cc96131afce ("dm: move request-based code out to dm-rq.[hc]")
we have a note: "DM targets should _never_ include dm-core.h!". And it
is not used in any DM targets except dm-raid now, so let's remove it
from dm-raid for consistency, also use special helpers instead of
accessing dm_table and mapper_device fields directly. This change is
merely a cleanup and should not affect functionality.

Fixes: 7168be3c8a6b ("md: record dm-raid gendisk in mddev")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 drivers/md/dm-raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index e8c0a8c6fb51..4fb5ddf50560 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -14,7 +14,6 @@
 #include "raid5.h"
 #include "raid10.h"
 #include "md-bitmap.h"
-#include "dm-core.h"
 
 #include <linux/device-mapper.h>
 
@@ -3305,7 +3304,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 
 	/* Disable/enable discard support on raid set. */
 	configure_discard_support(rs);
-	rs->md.dm_gendisk = ti->table->md->disk;
+	rs->md.dm_gendisk = dm_disk(dm_table_get_md(ti->table));
 
 	mddev_unlock(&rs->md);
 	return 0;
-- 
2.50.0


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

end of thread, other threads:[~2025-07-22  6:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18  9:22 [PATCH] arch: fix resource leak in chmc.c Jacky Liu
2025-07-18 13:25 ` Krzysztof Kozlowski
2025-07-21  2:04   ` jackysliu
2025-07-18 13:43 ` [PATCH] " Markus Elfring
2025-07-21  3:57   ` [PATCH v2] arch: fix resource leak in jbusmc_probe() jackysliu
2025-07-21  7:18     ` Markus Elfring
2025-07-21  7:55       ` [PATCH v3] sparc: " jackysliu
2025-07-21  8:17         ` Markus Elfring
2025-07-22  6:22         ` Krzysztof Kozlowski
2025-07-21  8:25     ` [PATCH v2] arch: " Krzysztof Kozlowski
  -- strict thread matches above, loose matches on Subject: below --
2025-07-21  3:49 [PATCH] dm-raid: do not include dm-core.h Pavel Tikhomirov
2025-07-21  3:56 ` [PATCH v2] arch: fix resource leak in jbusmc_probe() jackysliu

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.