Btrfs: fix double free in find_lock_delalloc_range
authorChris Mason <clm@fb.com>
Wed, 21 May 2014 12:49:54 +0000 (05:49 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:48 +0000 (13:33 +0100)
commit 7d78874273463a784759916fc3e0b4e2eb141c70 upstream.

We need to NULL the cached_state after freeing it, otherwise
we might free it again if find_delalloc_range doesn't find anything.

Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/btrfs/extent_io.c

index 73e4cbc..05937a8 100644 (file)
@@ -1523,6 +1523,7 @@ again:
                 * shortening the size of the delalloc range we're searching
                 */
                free_extent_state(cached_state);
+               cached_state = NULL;
                if (!loops) {
                        unsigned long offset = (*start) & (PAGE_CACHE_SIZE - 1);
                        max_bytes = PAGE_CACHE_SIZE - offset;