From patchwork Wed Nov 25 16:30:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1406133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UnGVWDTV; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ch5yl0KWjz9sTR for ; Thu, 26 Nov 2020 03:32:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9FD312E1AD; Wed, 25 Nov 2020 16:32:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nJqLpdsXzTk3; Wed, 25 Nov 2020 16:32:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 3C3C6203FC; Wed, 25 Nov 2020 16:32:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 12933C0891; Wed, 25 Nov 2020 16:32:25 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 51CF0C0052 for ; Wed, 25 Nov 2020 16:32:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 45DF9871B7 for ; Wed, 25 Nov 2020 16:32:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FRdrY78sTWaV for ; Wed, 25 Nov 2020 16:32:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5E5F28718E for ; Wed, 25 Nov 2020 16:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606321942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type; bh=o1KrpP9qHhbXpeoTh7yYi+iYSbga4GBfzOOPjB5xpno=; b=UnGVWDTV2hOeJQOtSqFtJq52dDt6etlg7c7+JfGOLmfIxb6PHQSMFi/80cmdbOVqYVqGtn AcllKtWfgCIYa/3tJIyZcdMmabrHRwqBWx0ZpUe66QoLpELN7MSmdtz9s3E6co9CNhgqUX f0WdB/z1fRT6XczaWcYowZbUGyiPlwM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-45jSXvcHP3GdcaAeRz2nuA-1; Wed, 25 Nov 2020 11:32:19 -0500 X-MC-Unique: 45jSXvcHP3GdcaAeRz2nuA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 921EB107ACE3; Wed, 25 Nov 2020 16:32:18 +0000 (UTC) Received: from dceara.remote.csb (ovpn-114-80.ams2.redhat.com [10.36.114.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id A25D09CA0; Wed, 25 Nov 2020 16:32:17 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Wed, 25 Nov 2020 17:30:30 +0100 Message-Id: <1606321830-28524-1-git-send-email-dceara@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] ovn-nbctl: Fix double-free of parsed commands on error path. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Reported-by: Daniel Alvarez Fixes: 8fb54e16378c ("ovn-nbctl: Cleanup allocated memory to keep valgrind happy.") Signed-off-by: Dumitru Ceara --- tests/ovn-nbctl.at | 12 ++++++++++++ utilities/ovn-nbctl.c | 17 ++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 11091d8..01edfcb 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1976,6 +1976,18 @@ AT_CHECK([ovn-nbctl list forwarding_group], [0], []) ]) +dnl --------------------------------------------------------------------- + +OVN_NBCTL_TEST([ovn_nbctl_negative], [basic negative tests], [ +AT_CHECK([ovn-nbctl --id=@ls create logical_switch name=foo -- \ + set logical_switch foo1 name=bar], + [1], [], [dnl +ovn-nbctl: no row "foo1" in table Logical_Switch +]) +]) + +dnl --------------------------------------------------------------------- + AT_SETUP([ovn-nbctl - daemon retry connection]) OVN_NBCTL_TEST_START daemon AT_CHECK([kill `cat ovsdb-server.pid`]) diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index a050f8d..d19e1b6 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -6430,12 +6430,6 @@ out_error: the_idl_txn = NULL; ovsdb_symbol_table_destroy(symtab); - for (c = commands; c < &commands[n_commands]; c++) { - ds_destroy(&c->output); - table_destroy(c->table); - free(c->table); - } - return error; } @@ -6851,17 +6845,18 @@ server_cmd_run(struct unixctl_conn *conn, int argc, const char **argv_, } else { ds_put_cstr(&output, ds_cstr_ro(&c->output)); } - - ds_destroy(&c->output); - table_destroy(c->table); - free(c->table); } unixctl_command_reply(conn, ds_cstr_ro(&output)); ds_destroy(&output); out: free(error); - for (struct ctl_command *c = commands; c < &commands[n_commands]; c++) { + + struct ctl_command *c; + for (c = commands; c < &commands[n_commands]; c++) { + ds_destroy(&c->output); + table_destroy(c->table); + free(c->table); shash_destroy_free_data(&c->options); } free(commands);