From patchwork Wed Sep 11 21:18:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 1161295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="e0Rq30IE"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46TFG42wSVz9s00 for ; Thu, 12 Sep 2019 07:21:48 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 92F7BDD0; Wed, 11 Sep 2019 21:18:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A0623D91 for ; Wed, 11 Sep 2019 21:18:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4359C81A for ; Wed, 11 Sep 2019 21:18:47 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id q10so14509813pfl.0 for ; Wed, 11 Sep 2019 14:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lPt2q0GQ48wgw24KsCPWQya+BNreKTqyqMqGV8UGzH4=; b=e0Rq30IEbeVjMOxS/mOEPN5uq7LSiHXYwfArHJ+J4VJAN0o7ak7vOm6+3vjq7+npn4 ttxXaAhWTIqFOhg9hV7GJ1hmZKaSJ5suF+T7lovf0/OOLN0UtLfwrVLsb53kIb2u06Ul 3iX2po2T1d0+2+wx0/LIVlh/5JbTrIDXXdRHNden2g0CFUM7QkQxnV57Uux87UJ015xb zivBwAq9WTf4UYAYriEHK1iiskmgyzVrOEBb0+Nu+DTCRGjldiP9HQLH71W361L681pM Fne/faqmx8pE4bu6/zFn3TmJPoCJIoTcAeU8LIwty5tLni3PTXOWHgz5vZO+CJmx8r7D QSfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lPt2q0GQ48wgw24KsCPWQya+BNreKTqyqMqGV8UGzH4=; b=M9TRs5o3OV6InUsd233FwF8BwBPBai6WHDP12epJ9+/79zSPIxudtXIoLT/+n9gJkJ vIFZwxLCAswBXWowvHwiRB0jfmqcpuaqut1+GUb5qXK4nbp3lvq13j9FR6QMBcarLdVe wKqF2I9P3Wd9yNi/Tkzmu9CmFnvipUqG547zS9t+ZhdZCcoSOAn0HkIOzdZU394YXROK zoAfMSWjtsd8OAW3XxWVAvgG4hT84ctuwtYQulAzOTIejsvghorQnQZCgIMneB32Z9Sd PjBfkI+w5DRBjtqUKeOiEN7tLCC15aRVYw4F+kDJplsDk27qZM9R9shLi3jqNzlMJoDk Biuw== X-Gm-Message-State: APjAAAUkizAT544Jc7Kl00JVXj20Ccdovv3Ihl0RY5poXl2hVv976go2 Xp8lkNCWNAhdgWJIeX4/Q1ri3z3i X-Google-Smtp-Source: APXvYqwLc2jMYK5Vpzi1a7VnNxsQXZIrp/F0D1mypk8hEK7ZmmAjsEewtyFvLoeb9Q+VHakQSLcH1w== X-Received: by 2002:a17:90a:a002:: with SMTP id q2mr7617758pjp.69.1568236726386; Wed, 11 Sep 2019 14:18:46 -0700 (PDT) Received: from kern417.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id k1sm24612487pfi.132.2019.09.11.14.18.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 14:18:45 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Wed, 11 Sep 2019 14:18:33 -0700 Message-Id: <1568236716-18105-7-git-send-email-pkusunyifeng@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1568236716-18105-1-git-send-email-pkusunyifeng@gmail.com> References: <1568236716-18105-1-git-send-email-pkusunyifeng@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 07/10] dns-resolve: Free 'struct ub_result' when callback returns error results X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Valgrind reported: 1074: ofproto - flush flows, groups, and meters for controller change ==5499== 695 (288 direct, 407 indirect) bytes in 3 blocks are definitely lost in loss record 344 of 355 ==5499== at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5499== by 0x5E7F145: ??? (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0) ==5499== by 0x5E6EBDE: ub_resolve_async (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0) ==5499== by 0x55C739: resolve_async__.part.5 (dns-resolve.c:233) ==5499== by 0x55C85C: resolve_async__ (dns-resolve.c:261) ==5499== by 0x55C85C: resolve_callback__ (dns-resolve.c:262) ==5499== by 0x5E6FEF1: ub_process (in /usr/lib/x86_64-linux-gnu/libunbound.so.2.4.0) ==5499== by 0x55CAF3: dns_resolve (dns-resolve.c:153) ==5499== by 0x523864: parse_sockaddr_components_dns (socket-util.c:438) ==5499== by 0x523864: parse_sockaddr_components (socket-util.c:504) ==5499== by 0x524468: inet_parse_active (socket-util.c:541) ==5499== by 0x524564: inet_open_active (socket-util.c:579) ==5499== by 0x5959F9: tcp_open (stream-tcp.c:56) ==5499== by 0x529192: stream_open (stream.c:228) ==5499== by 0x529910: stream_open_with_default_port (stream.c:724) ==5499== by 0x595FAE: vconn_stream_open (vconn-stream.c:81) ==5499== by 0x535C9B: vconn_open (vconn.c:250) ==5499== by 0x517C59: reconnect (rconn.c:467) ==5499== by 0x5184C7: run_BACKOFF (rconn.c:492) ==5499== by 0x5184C7: rconn_run (rconn.c:660) ==5499== by 0x457FE8: ofservice_run (connmgr.c:1992) ==5499== by 0x457FE8: connmgr_run (connmgr.c:367) ==5499== by 0x41E0F5: ofproto_run (ofproto.c:1845) ==5499== by 0x40BA63: bridge_run__ (bridge.c:2971) In ub_resolve_async's callback function, 'struct ub_result' should be finally freed even if there is a resolving error. This patch fixes it. Signed-off-by: Yifeng Sun Acked-by: William Tu --- lib/dns-resolve.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dns-resolve.c b/lib/dns-resolve.c index e98e65f493ed..1ff58960fe01 100644 --- a/lib/dns-resolve.c +++ b/lib/dns-resolve.c @@ -251,6 +251,7 @@ resolve_callback__(void *req_, int err, struct ub_result *result) struct resolve_request *req = req_; if (err != 0 || (result->qtype == ns_t_aaaa && !result->havedata)) { + ub_resolve_free(result); req->state = RESOLVE_ERROR; VLOG_ERR_RL(&rl, "%s: failed to resolve", req->name); return; @@ -265,6 +266,7 @@ resolve_callback__(void *req_, int err, struct ub_result *result) char *addr; if (!resolve_result_to_addr__(result, &addr)) { + ub_resolve_free(result); req->state = RESOLVE_ERROR; VLOG_ERR_RL(&rl, "%s: failed to resolve", req->name); return;