btrfs-progs: Check periodic.timer_fd's value before use
authorZhao Lei <zhaolei@cn.fujitsu.com>
Mon, 9 Nov 2015 09:06:53 +0000 (17:06 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 Nov 2015 13:23:45 +0000 (14:23 +0100)
periodic.timer_fd's value is 0 on inititlize-failed case,
if no value-checking before read(), the code will run as
read(STDIN).

This patch fixed above case.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
task-utils.c

index a4017ff..12b0002 100644 (file)
@@ -119,6 +119,9 @@ void task_period_wait(struct task_info *info)
        if (!info)
                return;
 
+       if (info->periodic.timer_fd == 0)
+               return;
+
        ret = read(info->periodic.timer_fd, &missed, sizeof (missed));
        if (ret == -1)
                return;