Skip to contentSkip to conversation

dm persistent data: test return value of node_copy

PATCH New Mikulas Patocka 2 participants 2 messages Nov 6 Device mapper

lore
Share & tools
lore

Mikulas Patocka

author maintainer
#0 lore raw

PATCH 1/1 dm persistent data: test return value of node_copy

There were 3 places where the return value of node_copy was not tested.

Assisted-by Claude:claude-opus-5
Fixes 3241b1d3e0aa ("dm: add persistent data library")
---
 drivers/md/persistent-data/dm-btree-remove.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/md/persistent-data/dm-btree-remove.c +10 -3
Index: linux-2.6/drivers/md/persistent-data/dm-btree-remove.c
===================================================================
@@ -253,7 +253,9 @@ static int __rebalance2(struct dm_btree_
 		/*
 		 * Merge
 		 */
-		node_copy(left, right, -nr_right);
+		ret = node_copy(left, right, -nr_right);
+		if (unlikely(ret))
+			return ret;
 		left->header.nr_entries = cpu_to_le32(nr_left + nr_right);
 		delete_at(parent, r->index);
 
@@ -315,13 +317,16 @@ static int delete_center_node(struct dm_
 {
 	uint32_t max_entries = le32_to_cpu(left->header.max_entries);
 	unsigned int shift = min(max_entries - nr_left, nr_center);
+	int ret;
 
 	if (nr_left + shift > max_entries) {
 		DMERR("node shift out of bounds");
 		return -EINVAL;
 	}
 
-	node_copy(left, center, -shift);
+	ret = node_copy(left, center, -shift);
+	if (unlikely(ret))
+		return ret;
 	left->header.nr_entries = cpu_to_le32(nr_left + shift);
 
 	if (shift != nr_center) {
@@ -333,7 +338,9 @@ static int delete_center_node(struct dm_
 		}
 
 		node_shift(right, shift);
-		node_copy(center, right, shift);
+		ret = node_copy(center, right, shift);
+		if (unlikely(ret))
+			return ret;
 		right->header.nr_entries = cpu_to_le32(nr_right + shift);
 	}
 	*key_ptr(parent, r->index) = right->keys[0];
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] dm persistent data: Fixes trailer cites wrong commit for node_copy() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] dm persistent data: Fixes trailer cites wrong commit for node_copy()
--

commit f0758e03fa9ea11bfbf4ab38d82540be653f4f13
Author: Mikulas Patocka <[email protected]>

Quoted 8 lines

dm persistent data: test return value of node_copy

There were 3 places where the return value of node_copy was not tested.

Assisted-by Claude:claude-opus-5
Fixes 3241b1d3e0aa ("dm: add persistent data library")

[Severity: Low]
In commit 3241b1d3e0aa ("dm: add persistent data library"), node_copy() returned void and used BUG_ON() for error checks. Commit c671ffa55d8b ("dm btree remove: change a bunch of BUG_ON() calls to proper errors") converted node_copy() to return an error code and left the three call sites in __rebalance2() and delete_center_node() unchecked. Should the Fixes tag be:

Fixes c671ffa55d8b ("dm btree remove: change a bunch of BUG_ON() calls to proper errors")
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1