Skip to content

Commit 2cf3f81

Browse files
committed
btrfs: fix lzo_decompress_bio() kmap leakage
Commit ccaa66c reinstated the kmap/kunmap that had been dropped in commit 8c945d3 ("btrfs: compression: drop kmap/kunmap from lzo"). However, it seems to have done so incorrectly due to the change not reverting cleanly, and lzo_decompress_bio() ended up not having a matching "kunmap()" to the "kmap()" that was put back. Also, any assert that the page pointer is not NULL should be before the kmap() of said pointer, since otherwise you'd just oops in the kmap() before the assert would even trigger. I noticed this when trying to verify my btrfs merge, and things not adding up. I'm doing this fixup before re-doing my merge, because this commit needs to also be backported to 5.15 (after verification from the btrfs people). Fixes: ccaa66c ("Revert 'btrfs: compression: drop kmap/kunmap from lzo'") Cc: David Sterba <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9c6e8d5 commit 2cf3f81

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/btrfs/lzo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
357357
ASSERT(cur_in / sectorsize ==
358358
(cur_in + LZO_LEN - 1) / sectorsize);
359359
cur_page = cb->compressed_pages[cur_in / PAGE_SIZE];
360-
kaddr = kmap(cur_page);
361360
ASSERT(cur_page);
361+
kaddr = kmap(cur_page);
362362
seg_len = read_compress_length(kaddr + offset_in_page(cur_in));
363+
kunmap(cur_page);
363364
cur_in += LZO_LEN;
364365

365366
/* Copy the compressed segment payload into workspace */

0 commit comments

Comments
 (0)