From: Zach Brown Date: Wed, 23 Jan 2013 20:18:32 +0000 (-0800) Subject: btrfs-progs: don't leak in set_extent_bits X-Git-Tag: upstream/4.16.1~3459^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09fac3824db462368f24d3dd4deccafedf5b3c8c;p=platform%2Fupstream%2Fbtrfs-progs.git btrfs-progs: don't leak in set_extent_bits It looks possible to hit the search_again label without using the prealloc. A new prealloc is allocated, leaking the current one. Every use of prealloc sets it to null so let's just allocate a new prealloc when we don't already have one. Signed-off-by: Zach Brown --- diff --git a/extent_io.c b/extent_io.c index ebb35b28..d59f2070 100644 --- a/extent_io.c +++ b/extent_io.c @@ -300,9 +300,11 @@ int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 last_start; u64 last_end; again: - prealloc = alloc_extent_state(); - if (!prealloc) - return -ENOMEM; + if (!prealloc) { + prealloc = alloc_extent_state(); + if (!prealloc) + return -ENOMEM; + } /* * this search will find the extents that end after