From patchwork Tue Jan 3 06:07:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhimanyu V X-Patchwork-Id: 710383 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tt3Pm2tMvz9t0q for ; Tue, 3 Jan 2017 17:07:24 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A92F9B802E9; Tue, 3 Jan 2017 07:07:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Tue, 3 Jan 2017 07:07:19 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 69AACB80112 for ; Tue, 3 Jan 2017 07:07:18 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .imgtec. - helo: .mailapp01.imgtec. - helo-domain: .imgtec.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by arrakis.dune.hu (Postfix) with ESMTP for ; Tue, 3 Jan 2017 07:07:16 +0100 (CET) Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id 26583CDE85C5F; Tue, 3 Jan 2017 06:07:13 +0000 (GMT) Received: from abhi-linux.pu.imgtec.org (192.168.91.133) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 3 Jan 2017 06:07:14 +0000 From: Abhimanyu V To: Date: Tue, 3 Jan 2017 11:37:05 +0530 Message-ID: <1483423625-6656-1-git-send-email-abhimanyu.vishwakarma@imgtec.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [192.168.91.133] Subject: [OpenWrt-Devel] [PATCH] ubus: ubus_free: clear pending timers before freeing context X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org, Marcin Nowakowski Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" From: Abhimanyu Vishwakarma If a synchronous operation is executed on a ubus context after uloop_done() has been called, the context's pending_timer may remain in uloop's list of timeouts. This leads to undefined behaviour during next execution of uloop code, as it may be referring to unavailable memory or memory that has been allocated for different purposes. Signed-off-by: Marcin Nowakowski Signed-off-by: Abhimanyu Vishwakarma --- libubus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libubus.c b/libubus.c index 8163ff7..a044003 100644 --- a/libubus.c +++ b/libubus.c @@ -362,6 +362,7 @@ void ubus_shutdown(struct ubus_context *ctx) if (!ctx) return; close(ctx->sock.fd); + uloop_timeout_cancel(&ctx->pending_timer); free(ctx->msgbuf.data); }