From patchwork Wed Feb 15 08:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1742750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.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=HSkg3VT4; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGsFB3kTxz23h0 for ; Wed, 15 Feb 2023 19:49:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C67E440A0D; Wed, 15 Feb 2023 08:48:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C67E440A0D Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HSkg3VT4 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OIIIJOn35ntr; Wed, 15 Feb 2023 08:48:58 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id D0DC6400B8; Wed, 15 Feb 2023 08:48:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D0DC6400B8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9FB7EC0033; Wed, 15 Feb 2023 08:48:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 19737C0032 for ; Wed, 15 Feb 2023 08:48:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DB2AA812B4 for ; Wed, 15 Feb 2023 08:48:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org DB2AA812B4 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HSkg3VT4 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hpYQBJhO6Bpx for ; Wed, 15 Feb 2023 08:48:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 23CCB812A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 23CCB812A1 for ; Wed, 15 Feb 2023 08:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676450934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+P10Bo4rPGYAxXfcdQvxxk/S4sMSzJxnngbJeduSduM=; b=HSkg3VT42EwzPmAGAg9xvEGQT1TwVBzRjRrq2a2nTpj7m26cOW8YJbESMym5y8nbYiaS9J Tephq/hYoqUPFG3YCw2OSD4n31MztstdNoiXejJLLHNrsgI00DsQvs8TS70f3DAvH+EAZ7 2rgD/6flrytPIc390Kz3I/Ojud8HSS4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-179-yxhRWt7qOQe6cTao4RxvAg-1; Wed, 15 Feb 2023 03:48:53 -0500 X-MC-Unique: yxhRWt7qOQe6cTao4RxvAg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C01E857F43; Wed, 15 Feb 2023 08:48:53 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.34.131.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id B414118EC1; Wed, 15 Feb 2023 08:48:52 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Wed, 15 Feb 2023 09:48:51 +0100 Message-Id: <20230215084852.255795-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH branch-2.17 1/2] dpctl: Fix memory leak in flush conntrack 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Direct leak of 36 byte(s) in 1 object(s) allocated from: #0 0x527d90 in __interceptor_realloc.part.0 asan_malloc_linux.cpp.o #1 0xc5f9fc in xrealloc__ /workspace/ovs/lib/util.c:147:9 #2 0xc5f9fc in xrealloc /workspace/ovs/lib/util.c:179:12 #3 0x86845d in ds_reserve /workspace/ovs/lib/dynamic-string.c:63:22 #4 0x86954a in ds_put_format_valist /workspace/ovs/lib/dynamic-string.c:164:9 #5 0x869202 in ds_put_format /workspace/ovs/lib/dynamic-string.c:142:5 #6 0x7dc664 in ct_dpif_parse_tuple /workspace/ovs/lib/ct-dpif.c #7 0xebb089 in dpctl_flush_conntrack /workspace/ovs/lib/dpctl.c:1717:17 #8 0xeb4eb2 in dpctl_unixctl_handler /workspace/ovs/lib/dpctl.c:3035:17 #9 0xc5d4f8 in process_command /workspace/ovs/lib/unixctl.c:310:13 #10 0xc5d4f8 in run_connection /workspace/ovs/lib/unixctl.c:344:17 #11 0xc5d4f8 in unixctl_server_run /workspace/ovs/lib/unixctl.c:395:21 #12 0x5a643f in main /workspace/ovs/vswitchd/ovs-vswitchd.c:130:9 Signed-off-by: Ales Musil --- lib/dpctl.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/dpctl.c b/lib/dpctl.c index 29041fa3e..742fbce2d 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -1727,26 +1727,23 @@ dpctl_flush_conntrack(int argc, const char *argv[], /* Report error if there are more than one unparsed argument. */ if (args > 1) { - ds_put_cstr(&ds, "invalid arguments"); error = EINVAL; - goto error; + dpctl_error(dpctl_p, error, "invalid arguments: %s", ds_cstr(&ds)); + goto out; } error = opt_dpif_open(argc, argv, dpctl_p, 4, &dpif); if (error) { - return error; + goto out; } error = ct_dpif_flush(dpif, pzone, ptuple); - if (!error) { - dpif_close(dpif); - return 0; - } else { - ds_put_cstr(&ds, "failed to flush conntrack"); + if (error) { + dpctl_error(dpctl_p, error, "failed to flush conntrack: %s", + ds_cstr(&ds)); } -error: - dpctl_error(dpctl_p, error, "%s", ds_cstr(&ds)); +out: ds_destroy(&ds); dpif_close(dpif); return error;