From patchwork Thu Oct 3 08:15:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damijan Skvarc X-Patchwork-Id: 1171105 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="lgNjj1Fy"; 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 46kQnR5jc6z9sCJ for ; Thu, 3 Oct 2019 18:16:10 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 124611147; Thu, 3 Oct 2019 08:16:08 +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 E6AAB113A for ; Thu, 3 Oct 2019 08:16:06 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7A7ECD3 for ; Thu, 3 Oct 2019 08:16:06 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id v8so1949797wrt.2 for ; Thu, 03 Oct 2019 01:16:06 -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; bh=jq02SpnZFkTFkllixcpQYdao+wuFhzXZs3AAzSJgo58=; b=lgNjj1FyBpUk4AnSW+INDWi+v0v0t84pIxcD3ue5CRpWilgrdmcSqTs3ybNHkLhGZ7 zV0y85ksV6L3AQlEPRCqWdvJKxc1rd4x6xw/Qbaj3JgLK+IxMBHDvgBv876k0on8qswj IAjtoqnJE/D3D0OXGSht+yi7tOsY+rCpVLPkVwlJf6eCQxl+kUA/xWjazXJ5Dq3FLvdP PbYZAdvGWzsbhbkrOTGWp68+VNfF7UguPinC/02c/hSHfkJRJtKHcqb5pE9FX6HO1ANH Ksk0ITBrJL4xp5HxpLnWPX/W5MuZkMrELlj71hIfvdD3szvFwN79cXmcz2G4ChlH/2rK T0Pg== 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; bh=jq02SpnZFkTFkllixcpQYdao+wuFhzXZs3AAzSJgo58=; b=TC9kprZpPG5goQvA5odYXAQfXVQCsvtYcDbHfl/kkCgOA6frnw7CbwdwMq2j1pXTgX faqe04klbMXbZFnpLWd7SQpf+snAnMluQjOOhLbCUYQ5xz4hwMpriel9Nc+weKaEFO1U xUrBotnJxklU+olWv8VjWIKyK9TuNRRA7TaMFk8xc1mojh2s/ViFSyanUvPNPcyOnvDd gUg5p6mSb6+pnVxNilFwwsPZJEaGd7I0ozTNGgLG84NfC8W9W+LdseDF2yBW012SxYQu mSsKFcdRETn7STstWU29ai4ttLh46xwQ53nRaVNWVW21H9Fm4xtkMGKYOs+kUPUE0XtN Bx8g== X-Gm-Message-State: APjAAAUEXLtPyK+Xe7htkHJIEiU6r/888QWT5DIs7Vg0cRIYoNyOy5XA GZNnqvQB7PqSyHpbGXGTcSEYLrFSgm8= X-Google-Smtp-Source: APXvYqwfXuKeuxPWEA1nv9d3bsK0I55LT+syE4ISmzWp2gRqRsXdceez1aTWCsSnI1CQyw/dh7mR3A== X-Received: by 2002:a5d:4350:: with SMTP id u16mr6215615wrr.289.1570090564343; Thu, 03 Oct 2019 01:16:04 -0700 (PDT) Received: from damijan-PC.i-tech.local (mail.i-tech.si. [89.212.78.105]) by smtp.gmail.com with ESMTPSA id x5sm3593388wrg.69.2019.10.03.01.16.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Oct 2019 01:16:03 -0700 (PDT) From: Damijan Skvarc To: dev@openvswitch.org Date: Thu, 3 Oct 2019 10:15:59 +0200 Message-Id: <1570090559-17150-1-git-send-email-damjan.skvarc@gmail.com> X-Mailer: git-send-email 2.7.4 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 1/1] ofproto-dpif-xlate: fixed memory leak in is_neighbor_reply_correct() function 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 memory leak happens while calling netdev_get_addr_list() function. This function allocates memory for ip_addr and mask output arguments, but this memory is never freed. Signed-off-by: Damijan Skvarc --- ofproto/ofproto-dpif-xlate.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 9c31c06..44f856d 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4027,10 +4027,14 @@ is_neighbor_reply_correct(const struct xlate_ctx *ctx, const struct flow *flow) HMAP_FOR_EACH (port, ofp_node, &ctx->xbridge->xports) { error = netdev_get_addr_list(port->netdev, &ip_addr, &mask, &n_in6); - if (!error && is_neighbor_reply_matched(flow, ip_addr)) { - /* Found a match. */ - ret = true; - break; + if (!error) { + ret = is_neighbor_reply_matched(flow, ip_addr); + free(ip_addr); + free(mask); + if (ret) { + /* Found a match. */ + break; + } } } }