From patchwork Fri Aug 2 12:14:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damijan Skvarc X-Patchwork-Id: 1141142 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="BXgyBbDO"; 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 460R1G6d3lz9sDB for ; Fri, 2 Aug 2019 22:14:41 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9D71FCBC; Fri, 2 Aug 2019 12:14:38 +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 6A9971225 for ; Fri, 2 Aug 2019 12:14:16 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E1ACD712 for ; Fri, 2 Aug 2019 12:14:15 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id r1so76906611wrl.7 for ; Fri, 02 Aug 2019 05:14:15 -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=BhYgOS+1GQHf4aWjQhdWP1yDiPcMiiab0yeGRQ+wxj8=; b=BXgyBbDOc/jjztRhdFpAoCMpxyRnFGs4JOxWSn9dkaWuvndlQwAPIig20ezH/0AgI6 EVpJilaJ1sL2wuzA/44HK274B6rhfmUG5zlJewEjc8wcDEEIs1tSjH6L+gc7PGRuBXgk E3uvzt4aXghK9N0mPgng1YyrVk1gZ/js0dYxFmGj9XMrLrgP877L+qJI2vBy3I5bvTBK FC/NEdE0yOvLBpLf4UBg5Gje2s2nllDfUo63Ch4UGTIjh5JloCoktkaSI7bxLKyW8C0F 4Nlg3lAhqSOGCDy53BD8bkZUaPESVvmYrvJk4VI1oUCek0aM6cwSDA+l+IVFq/Mx14PY 1F7A== 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=BhYgOS+1GQHf4aWjQhdWP1yDiPcMiiab0yeGRQ+wxj8=; b=ahMwNZpZdWVeMi5AbSbxGUK5lvBfGrfHKUtIY4zWaYUsmgDsh3apCaELHWgnDknmcK yLHO4dsVjpNojTPBY/SiwSiv1nCpyhBeuBbXrCcMlWIkI3lWNU5HDK5tbgZbkSUwce8N 4TQC9i0+x7r3sNqxiWHUGkyPnXSPoNOcM1WPpo6ONg+ocRAqx88xLbIJ1cdIUGiih9H9 6ROppduLxXqcdZuSKvkEz2bFJPzcM2A3OSw80nE/pwiWXVZGQyRI8m9dW0FIifSYEagI HLgB0qrVro2F02s/+uTamuslWyQVsXNhakECZ2CA6KZ6ZTnfjbEbtAyCmNqJ5Okcae+U bu6w== X-Gm-Message-State: APjAAAUZCBd3o/mqbThiBQOux+VukFkzY/gBaY6vl+ZYg/3SB8Ram5OO dSRAoNxTGLpFrvJEHSxStj0KefNO X-Google-Smtp-Source: APXvYqwm1fF1uj+IBQZMMK6VqrZ6sshFcjz3Yn3E4GTv4Ng2cJG1bPxM4gN83GPOuBV1/MV67kUasQ== X-Received: by 2002:a5d:4cc5:: with SMTP id c5mr92655681wrt.278.1564748054013; Fri, 02 Aug 2019 05:14:14 -0700 (PDT) Received: from damijan-PC.i-tech.local (mail.i-tech.si. [89.212.78.105]) by smtp.gmail.com with ESMTPSA id r14sm65250440wrx.57.2019.08.02.05.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Aug 2019 05:14:12 -0700 (PDT) From: Damijan Skvarc To: dev@openvswitch.org Date: Fri, 2 Aug 2019 14:14:01 +0200 Message-Id: <1564748041-12962-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] ovn-northd: fixed memory leak in ovn_port_update_sbrec() 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 because of redundand memory allocation for array of single pointer. Issue was solved by removing this redundand allocation and using address of pointer to created chassis sb_ha_entity instead. Signed-off-by: Damijan Skvarc Acked-by: Numan Siddique --- northd/ovn-northd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index cd776fa..d99ae67 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -2506,12 +2506,10 @@ ovn_port_update_sbrec(struct northd_context *ctx, } if (sb_ha_ch_grp->n_ha_chassis != 1) { - struct sbrec_ha_chassis **sb_ha_ch = - xcalloc(1, sizeof *sb_ha_ch); - sb_ha_ch[0] = create_sb_ha_chassis(ctx, chassis, + struct sbrec_ha_chassis *sb_ha_ch = create_sb_ha_chassis(ctx, chassis, chassis->name, 0); sbrec_ha_chassis_group_set_ha_chassis(sb_ha_ch_grp, - sb_ha_ch, 1); + &sb_ha_ch, 1); } sbrec_port_binding_set_ha_chassis_group(op->sb, sb_ha_ch_grp);