]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Btrfs: avoid possible NULL deref in io_ctl_drop_pages()
authorLi Zefan <lizf@cn.fujitsu.com>
Mon, 9 Jan 2012 06:27:42 +0000 (14:27 +0800)
committerLi Zefan <lizf@cn.fujitsu.com>
Wed, 11 Jan 2012 02:26:34 +0000 (10:26 +0800)
If we run into some failure path in io_ctl_prepare_pages(),
io_ctl->pages[] array may have some NULL pointers.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
fs/btrfs/free-space-cache.c

index 01840ef95a32b7a56ecf3c17f2ab0deebf7bc85b..4e55af333e19485cb9ab4598df8b98a2c0874258 100644 (file)
@@ -319,9 +319,11 @@ static void io_ctl_drop_pages(struct io_ctl *io_ctl)
        io_ctl_unmap_page(io_ctl);
 
        for (i = 0; i < io_ctl->num_pages; i++) {
-               ClearPageChecked(io_ctl->pages[i]);
-               unlock_page(io_ctl->pages[i]);
-               page_cache_release(io_ctl->pages[i]);
+               if (io_ctl->pages[i]) {
+                       ClearPageChecked(io_ctl->pages[i]);
+                       unlock_page(io_ctl->pages[i]);
+                       page_cache_release(io_ctl->pages[i]);
+               }
        }
 }