Btrfs-progs: fix segfault when getting scrub status
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>
Wed, 4 Dec 2013 09:24:36 +0000 (17:24 +0800)
committerChris Mason <clm@fb.com>
Fri, 31 Jan 2014 16:22:12 +0000 (08:22 -0800)
I sometimes get segfault in cmd_scrub_status(), this is because
free_history() forgot to check whether pointer address is valid,fix it.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
cmds-scrub.c

index 25d4ef5..31486df 100644 (file)
@@ -285,7 +285,7 @@ static void print_fs_stat(struct scrub_fs_stat *fs_stat, int raw)
 static void free_history(struct scrub_file_record **last_scrubs)
 {
        struct scrub_file_record **l = last_scrubs;
-       if (!l)
+       if (!l || IS_ERR(l))
                return;
        while (*l)
                free(*l++);