From patchwork Wed Sep 11 21:18:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Sun X-Patchwork-Id: 1161297 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="MGRT4n6j"; 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 46TFGz3jwxz9s00 for ; Thu, 12 Sep 2019 07:22:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F2AC2E36; Wed, 11 Sep 2019 21:18:50 +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 B1407DAF for ; Wed, 11 Sep 2019 21:18:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5BC7281A for ; Wed, 11 Sep 2019 21:18:48 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id y10so10707326pll.7 for ; Wed, 11 Sep 2019 14:18:48 -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=wW9EruWOWKQvr+akIV2FCQ5JrbEW0IVSOc0OVy6+YTc=; b=MGRT4n6jECcXI9ML55gyV+WFQnW86gc0ZDPAL1r5VoR6k3f7CDcyPj1fNDYt/Hi8Vv wCfk5kTDxvUAchh6Lv7lQ6XjwnU95nunOOf21DiKwbUaL0TZ1yUeVFGnT1yMElQAezJB fHX8L3zKzQr/YKCVKsgD77O6meMb2ueS945bLDKqHPW5wIVgHL1cxA1oxATizRtiF+08 Qt5Wm8mHOUq+BW19PgczZaNJsPqJVjYsnjbyH+M0SlSqbplBxfy4qr/mIs9KnXVDUjMK Hrj/jUzhx097jtNuY1UrPhUidWt5VgxY4aivwJB4S1gpsKFREQsgqfZa9lB6OtRBethg KYZg== 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=wW9EruWOWKQvr+akIV2FCQ5JrbEW0IVSOc0OVy6+YTc=; b=IXdysu9z2zWD6CN1JrKlFODUDX5FvNbFWQsRuUCyXp+ntJv1UuEOhwas+bMceKmIHv sxgvr0biqsZM1UKS0moA3hoVqZ0Jx9CcOt7Kf1MoAMFLy3oQmo9VgaArojrJqtynJa96 YJPMQ/bctRdgRIWKC8VN/vptHLL6yw30eP/z71u4K03Egh4GrQJo35mB+WjXR8cnmtKi lDMAkESSDTDfIu/E0Rf0Ufm74KCdqJaxZMMmIARh7E8Kph4SkE8H0Tuz1JrjEG9yi0rG P4AgaiIAM50GKYJICWb11F+CZ0v7rbcqo8F7eRUE725IcoNpbSCf5DMZpaaNf7fRW7ZQ dYcQ== X-Gm-Message-State: APjAAAUmXgcoTjYV53AQsi5vQ7YMZckJontrKsWj0eEIv6dmVav6SWBm ETLpftHnTRo4QnRTAfnm6ChC8gLh X-Google-Smtp-Source: APXvYqw3qiSJzN0W2e0eSTeHIDaCCnbG4rbsaRSIa5XjGvJaeFU/SUU1iiybWeUz6YWwinCqBewQHw== X-Received: by 2002:a17:902:8f8e:: with SMTP id z14mr18186553plo.323.1568236727655; Wed, 11 Sep 2019 14:18:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Sep 2019 14:18:47 -0700 (PDT) From: Yifeng Sun To: dev@openvswitch.org Date: Wed, 11 Sep 2019 14:18:35 -0700 Message-Id: <1568236716-18105-9-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 09/10] db-ctl-base: Free leaked ovsdb_datum 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: 2491: database commands -- negative checks ==19245== 36 (32 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 36 of 53 ==19245== at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==19245== by 0x431AB4: xrealloc (util.c:149) ==19245== by 0x41656D: ovsdb_datum_reallocate (ovsdb-data.c:1883) ==19245== by 0x41656D: ovsdb_datum_union (ovsdb-data.c:1961) ==19245== by 0x4107B2: cmd_add (db-ctl-base.c:1494) ==19245== by 0x406E2E: do_vsctl (ovs-vsctl.c:2626) ==19245== by 0x406E2E: main (ovs-vsctl.c:183) ==19252== 16 bytes in 1 blocks are definitely lost in loss record 9 of 52 ==19252== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==19252== by 0x430F74: xmalloc (util.c:138) ==19252== by 0x414D07: clone_atoms (ovsdb-data.c:990) ==19252== by 0x4153F6: ovsdb_datum_clone (ovsdb-data.c:1012) ==19252== by 0x4104D3: cmd_remove (db-ctl-base.c:1564) ==19252== by 0x406E2E: do_vsctl (ovs-vsctl.c:2626) ==19252== by 0x406E2E: main (ovs-vsctl.c:183) This patch fixes them. Signed-off-by: Yifeng Sun Acked-by: William Tu --- lib/db-ctl-base.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index 3bd9f006acb1..6878d6326cae 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1489,6 +1489,7 @@ cmd_add(struct ctl_context *ctx) ctx->error = ovsdb_datum_from_string(&add, &add_type, ctx->argv[i], ctx->symtab); if (ctx->error) { + ovsdb_datum_destroy(&old, &column->type); return; } ovsdb_datum_union(&old, &add, type, false); @@ -1500,6 +1501,7 @@ cmd_add(struct ctl_context *ctx) old.n, type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs", column->name, table->name, type->n_max); + ovsdb_datum_destroy(&old, &column->type); return; } ovsdb_idl_txn_verify(row, column); @@ -1581,10 +1583,12 @@ cmd_remove(struct ctl_context *ctx) ctx->argv[i], ctx->symtab); if (ctx->error) { + ovsdb_datum_destroy(&old, &column->type); return; } } else { ctx->error = error; + ovsdb_datum_destroy(&old, &column->type); return; } } @@ -1596,6 +1600,7 @@ cmd_remove(struct ctl_context *ctx) "table %s but the minimum number is %u", old.n, type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs", column->name, table->name, type->n_min); + ovsdb_datum_destroy(&old, &column->type); return; } ovsdb_idl_txn_verify(row, column);