Skip to contentSkip to conversation

dm-raid: do not include dm-core.h

PATCH Applied Pavel Tikhomirov 4 participants 4 messages Jul 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-raid: do not include dm-core.h

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")
---
 drivers/md/dm-raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-raid.c +1 -2
index e8c0a8c6fb51..4fb5ddf50560 100644
@@ -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;
Signature · 1 line
2.50.0
#1 lore raw

PATCH v2 1/1 arch: fix resource leak in jbusmc_probe()

From: Siyang Liu <[email protected]>

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.

---
 arch/sparc/kernel/chmc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/sparc/kernel/chmc.c +7 -3
index d4c74d6b2e1b..fd20e4ee0971 100644
@@ -412,7 +412,7 @@ static int jbusmc_probe(struct platform_device *op)
 	mem_regs = of_get_property(mem_node, "reg", &len);
 	if (!mem_regs) {
 		printk(KERN_ERR PFX "Cannot get reg property of /memory node.\n");
-		goto out;
+		goto out_put;
 	}
 	num_mem_regs = len / sizeof(*mem_regs);
 
@@ -420,7 +420,7 @@ static int jbusmc_probe(struct platform_device *op)
 	p = kzalloc(sizeof(*p), GFP_KERNEL);
 	if (!p) {
 		printk(KERN_ERR PFX "Cannot allocate struct jbusmc.\n");
-		goto out;
+		goto out_put;
 	}
 
 	INIT_LIST_HEAD(&p->list);
@@ -473,6 +473,10 @@ static int jbusmc_probe(struct platform_device *op)
 
 	err = 0;
 
+out_put:
+	of_node_put(mem_node);
+	goto out;
+
 out:
 	return err;
 
@@ -481,7 +485,7 @@ static int jbusmc_probe(struct platform_device *op)
 
 out_free:
 	kfree(p);
-	goto out;
+	goto out_put;
 }
 
 /* Does BANK decode PHYS_ADDR? */
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#2 lore raw
In reply to Pavel Tikhomirov
Quoted 7 lines · Pavel Tikhomirov

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.

Quoted 6 lines
Fixes 7168be3c8a6b ("md: record dm-raid gendisk in mddev")
---
  drivers/md/dm-raid.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

Thanks

Quoted 22 lines
drivers/md/dm-raid.c +1 -2
index e8c0a8c6fb51..4fb5ddf50560 100644
@@ -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;
maintainer Applied
#3 lore raw
In reply to Pavel Tikhomirov
Quoted 37 lines · Pavel Tikhomirov

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")
---
 drivers/md/dm-raid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-raid.c +1 -2
index e8c0a8c6fb51..4fb5ddf50560 100644
@@ -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;
Signature · 1 line
2.50.0

Applied, thanks.

(I deleted the Fixes line, because it is not really a bugfix and it doesn't have to be backported to the stable kernel branches)

Mikulas