dm persistent data: test return value of node_copy
Mikulas Patocka
maintainerPATCH 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.
--- 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
@@ -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 ];
[email protected]
AI reviewThank 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_copyThere were 3 places where the return value of
node_copywas not tested.Signed-off-by Mikulas Patocka <[email protected]>Assisted-by Claude:claude-opus-5Fixes 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:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1