Skip to content

Commit 6e5aafb

Browse files
committed
Btrfs: fix kfree on list_head in btrfs_lookup_csums_range error cleanup
If we hit any errors in btrfs_lookup_csums_range, we'll loop through all the csums we allocate and free them. But the code was using list_entry incorrectly, and ended up trying to free the on-stack list_head instead. This bug came from commit 0678b61 btrfs: Don't BUG_ON kzalloc error in btrfs_lookup_csums_range() Signed-off-by: Chris Mason <[email protected]> Reported-by: Erik Berg <[email protected]> cc: [email protected] # 3.3 or newer
1 parent d05a2b4 commit 6e5aafb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/file-item.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
413413
ret = 0;
414414
fail:
415415
while (ret < 0 && !list_empty(&tmplist)) {
416-
sums = list_entry(&tmplist, struct btrfs_ordered_sum, list);
416+
sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list);
417417
list_del(&sums->list);
418418
kfree(sums);
419419
}

0 commit comments

Comments
 (0)