From patchwork Mon Jul 27 06:27:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 6869261 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EC913C05AC for ; Mon, 27 Jul 2015 06:30:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F6262062B for ; Mon, 27 Jul 2015 06:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 307D42062E for ; Mon, 27 Jul 2015 06:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751733AbbG0G3i (ORCPT ); Mon, 27 Jul 2015 02:29:38 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:24888 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751311AbbG0G3h (ORCPT ); Mon, 27 Jul 2015 02:29:37 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="98920046" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Jul 2015 14:33:11 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6R6RiRE003810 for ; Mon, 27 Jul 2015 14:27:44 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 27 Jul 2015 14:29:33 +0800 From: Zhaolei To: CC: Zhao Lei Subject: [PATCH v2 4/7] btrfs-progs: resst info->periodic.timer_fd's value after free Date: Mon, 27 Jul 2015 14:27:51 +0800 Message-ID: X-Mailer: git-send-email 1.8.5.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhao Lei task_period_stop() is used to close a timer explicitly, to avoid the timer handle closed again by task_stop(), we should reset its value after close. Also add value-reset for info->id for safe. Signed-off-by: Zhao Lei --- task-utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/task-utils.c b/task-utils.c index 17fd573..768be94 100644 --- a/task-utils.c +++ b/task-utils.c @@ -64,10 +64,13 @@ void task_stop(struct task_info *info) if (info->id > 0) { pthread_cancel(info->id); pthread_join(info->id, NULL); + info->id = -1; } - if (info->periodic.timer_fd) + if (info->periodic.timer_fd) { close(info->periodic.timer_fd); + info->periodic.timer_fd = 0; + } if (info->postfn) info->postfn(info->private_data); @@ -130,5 +133,6 @@ void task_period_stop(struct task_info *info) if (info->periodic.timer_fd) { timerfd_settime(info->periodic.timer_fd, 0, NULL, NULL); close(info->periodic.timer_fd); + info->periodic.timer_fd = -1; } }