btrfs-progs: Check periodic.timer_fd's value before use

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>
master
Zhao Lei 2015-11-09 17:06:53 +08:00 committed by David Sterba
parent 1b9876f761
commit f3fbb9a398
1 changed files with 3 additions and 0 deletions

View 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;