5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit b27523a0781aae0b51ac13f29dc65373d14b8434 upstream. If find_leaf fails, the function dm_btree_cursor_begin would return an error, but it would keep the dm-bufio buffers held. This would result in a memory leak and a warning when releasing the dm-bufio cache. This commit fixes it, so that dm_btree_cursor_begin releases the buffers on error. Signed-off-by: Mikulas Patocka Assisted-by: Claude:claude-opus-5 Cc: stable@vger.kernel.org Fixes: 7d111c81fa29 ("dm btree: introduce cursor api") Signed-off-by: Greg Kroah-Hartman --- drivers/md/persistent-data/dm-btree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/drivers/md/persistent-data/dm-btree.c +++ b/drivers/md/persistent-data/dm-btree.c @@ -1506,7 +1506,13 @@ int dm_btree_cursor_begin(struct dm_btre if (r) return r; - return find_leaf(c); + r = find_leaf(c); + if (unlikely(r)) { + dm_btree_cursor_end(c); + return r; + } + + return 0; } EXPORT_SYMBOL_GPL(dm_btree_cursor_begin);