diff mbox

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

Message ID bbf60367447e680378412a801a881496aa25fe60.1447060006.git.zhaolei@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Zhaolei Nov. 9, 2015, 9:06 a.m. UTC
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>
---
 task-utils.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Sterba Nov. 13, 2015, 4:40 p.m. UTC | #1
On Mon, Nov 09, 2015 at 05:06:53PM +0800, Zhao Lei wrote:
> 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>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/task-utils.c b/task-utils.c
index a4017ff..12b0002 100644
--- a/task-utils.c
+++ b/task-utils.c
@@ -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;