From patchwork Fri Jul 9 11:44:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: miter X-Patchwork-Id: 1503055 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=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=hsFz+mBY; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GLrsq3829z9sV8 for ; Fri, 9 Jul 2021 21:44:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 71DDB83D42; Fri, 9 Jul 2021 11:44:12 +0000 (UTC) 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 EGmBrVOnvhTl; Fri, 9 Jul 2021 11:44:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id B71F983D3A; Fri, 9 Jul 2021 11:44:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 98622C001A; Fri, 9 Jul 2021 11:44:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id CDAD7C000E for ; Fri, 9 Jul 2021 11:44:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id AF13C41D1B for ; Fri, 9 Jul 2021 11:44:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=outlook.com 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 aSRCHo3OpPkJ for ; Fri, 9 Jul 2021 11:44:07 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2154.outbound.protection.outlook.com [40.92.63.154]) by smtp2.osuosl.org (Postfix) with ESMTPS id C50BF4058B for ; Fri, 9 Jul 2021 11:44:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hrwtgC48K0GNPCIlJ4o8YtK+coJXQ7xV0PVJJK40RL3+CQ4bhqHtSq7mNlXGTXixmWtQ4EFLELBxndDKg+NlOSb5UeMonIis004TE9WaayC3nTI1P5NsdBEMMbog0tu2HdlDv2CyyiNyc7nEG55gRcwZv9RR22fS1dANJUbQIWwB6UdIhlC+lrGXHOcW7JdxCMO94UkbSTOCtoDuLfKnO0sDKH3QHCEj3EZxIZTT6bGwNQEzbeVMyW67M9V575JkerbOZUNEL5lxRvDhAa9kPB+3vqBCgT40cJ9nujpBffSQYS2pqJSilc50TiuEizR2MN4m+JibGdyiwlTCT/fQKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v+vdaWj6p4qxkmKor3GNId00vzvnVi8mBf6OVw2froo=; b=PA2n7GLovAYfZkhHyEZsMdT6+f6hLCQFyF4yjZQ3NxPB+5ZI4xKrnQVdtEzmtzmjGM4OzeBoVReJarvPZHr5fRF6DJDG5vDGeu9boVL0BE8dSv7ELBR6qZG5rsImZuno2FdvfSmF2D/OwSDfpyh8Qp0o72GpaPoGM1GT61663PJaV2RpvQk1b/Q5BI/Fec83L5j2CKPX46sz7PtlAGlzFlbO52WkeCPavAcfKNiS7AS/7RLlydGvFJebiem2+l6fA0ftHoOZDnS4zKCuz/fOteD+OOT0violbCDiL55YnI9kLCzbgKkHwEbqSFVIINUCrfkhMImiZrAXSKNZ4bR5Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v+vdaWj6p4qxkmKor3GNId00vzvnVi8mBf6OVw2froo=; b=hsFz+mBYfEezyuknH7VOje0Y0Lb6/8XnPZY0p7Ha8y7kABA21eCjTz6I+zg+PvQaHoBMyl6OqDyoVESoO2GNGAfjy4JHFZtcbNY1RryVR+yIbL6vg91UcRCR4ASX62fYM3pBeftsqwNSZ3ZqCVM/vDSimse+3Kz/48eIYxzS/tOkdwJbpNVEw8SCMUj8MyuxwYFPpE1ed1xzA41gH3UTrkt7i/r4iM4jX9POMgdKhNFoW9WMxcKSMXrKttxFyY+Uqi2V7L8Ktb9M0CWx7jHaIuWorMiJrGkyJiey0tHsCWoKRembirntZcWwwtVp0ExOy0YGL83N+Cc72QPdM9S3mw== Received: from MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:15b::24) by ME3P282MB3087.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:130::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Fri, 9 Jul 2021 11:44:02 +0000 Received: from MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM ([fe80::dd71:a32a:32de:975]) by MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM ([fe80::dd71:a32a:32de:975%5]) with mapi id 15.20.4308.023; Fri, 9 Jul 2021 11:44:02 +0000 From: lin huang To: "dev@openvswitch.org" , Ben Pfaff Thread-Topic: [PATCH] ovsdb-tool.c : Fix memory leak report by coverity Thread-Index: AQHXdLeWr590/sP2xUKezIWXmAL1xw== Date: Fri, 9 Jul 2021 11:44:01 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-tmn: [22bWpDJYLLElxfLmu93td1uhJ1xIKk6K] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 55344f3a-8841-47d0-c672-08d942ced8ff x-ms-traffictypediagnostic: ME3P282MB3087: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kp7Drch+5TJON/pWz+RkSa83j26M59qqzBucBXfFKrsugVGSzSx5NBIByTb0S4K+/pwFtHG37JqaGmgEgzrhs/8Iivc02G1CtLBKipTrW1i0ye3fC9Czw/w4zxdbDwIhsabbI3QW3zCsi1EE/XTMc5HGiqCYBdN8T1+qV88nW3/iOgMBEOKQxCgPy26fU4059PveFEpkaVJ201czkIjw/E7MTrqtn6x5X3++UBbxpn5cvXqcW6ZDCTuSrAPpSDqDCylti4lxDrBDgQyc1Ai4rbVEbcr1ktDyJYBIAkZK50O5s+qMZJA9auI7xcTPkoYrBr+KNNEJAhBnrY12Wj9O/V7owVRvwBPiitF5aJsfSY/Bx+EFQTq8WagEMlKqIF60Xfyxyp+iVWqSaJTzhnrpdATr5mlwPLJFGATULotBOIzwu00tCsUOkwqUyNFdiLF6 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: Ld/QbMyoVb5rOLfkk2lWBO7oTfgkXbFfELJq3eIitjXdT3k9olt2cA/Kz1+hXkj/5W/3N63CPQ7tj/2IafhjEMjMDlo9pwP8YqCDZ3pvVupyfOqAix1tIhQvxJ8hnbV1Ov66Q6TKk6++/9MfpHmugw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB3302.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 55344f3a-8841-47d0-c672-08d942ced8ff X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2021 11:44:02.0037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ME3P282MB3087 Subject: [ovs-dev] [PATCH] ovsdb-tool.c : Fix memory leak report by coverity 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" Call json_destroy() after json_object_create. Signed-off-by: linhuang --- ovsdb/ovsdb-tool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index 7a8997bba..05a0223e7 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -1508,12 +1508,16 @@ do_check_cluster(struct ovs_cmdl_context *ctx) if (!must_equal || raft_entry_equals(ae, be)) { continue; } - char *as = json_to_string(raft_entry_to_json(ae), JSSF_SORT); - char *bs = json_to_string(raft_entry_to_json(be), JSSF_SORT); + struct json *jae = raft_entry_to_json(ae); + struct json *jbe = raft_entry_to_json(be); + char *as = json_to_string(jae, JSSF_SORT); + char *bs = json_to_string(jbe, JSSF_SORT); ovs_fatal(0, "log entries with index %"PRIu64" differ:\n" "%s has %s\n" "%s has %s", idx, a->filename, as, b->filename, bs); + json_destroy(jae); + json_destroy(jbe); } } }