From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53244A04E1; Tue, 22 Sep 2020 12:26:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3230B1DB48; Tue, 22 Sep 2020 12:26:54 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 7DA6E1DB43 for ; Tue, 22 Sep 2020 12:26:52 +0200 (CEST) IronPort-SDR: s7JsVnlPmmniNJSBT/PZLU89fT5VqnTMGVsKQweK0V88xuCuAADc/NX3L75QFPGczitym1jStK xSMCKiiVzTkA== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="222168844" X-IronPort-AV: E=Sophos;i="5.77,290,1596524400"; d="scan'208";a="222168844" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2020 03:26:51 -0700 IronPort-SDR: H0Pr/47Ajnz/AC7FfmcpqWXss588Xnyf+Pwh+uy4JErF/RaACA1NgcBJCfM+MkMkhB8+9PePxM lQHrj93V9dEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,290,1596524400"; d="scan'208";a="346890153" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2020 03:26:50 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 22 Sep 2020 03:26:50 -0700 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 22 Sep 2020 03:26:50 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 22 Sep 2020 03:26:50 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.36.59) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 22 Sep 2020 03:26:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJ78IpyGPIgdbax+o2ZzKj8G0DzezoBjUd2Xl4VrbBr8hW3bYhn4CYcTLvu7SFqfiwyJ/2oynosC0mjw/jvADL13/k2ZTdQRyJzkNBRuNNcfMTq949ZvdR9QOo9iE6j36s7rXdbhff//x3OijjCW5DeJa9f8dAkFSBdnOg+jarxVHSk4uvpl5egkGiJDAiQ6rAjQksGIKHE15znXgnbEmrRIaZWiBTrucwavgNdcXe1JMj/b/d2VToxdyUUNNCYjTY/TNZOVUJcwj3psLnfNDwrdoth0xs1dod31+tNNk3FrxRY/Bg0B8ROUFAhn998rzJTihJgwFkgkkQUZOPR+3Q== 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=eXYAhY/HtL7puT9vPIIaaLMyQDKP1w0bPp0lsPFNNdQ=; b=J9feWr6B6B4aTHoSDYJ/s6tEavlABY6VaiJDjVn1vMcqJNMqjlkenmzqXLeJGepnpMLj3ClQu4JKL+yO/sBsq7bv/ANlTuoWhj40NyvuWwD2nQlfXxlgQr+VffKxhE7+imuu0Om2oypJ7KwcrxS0TNon/UnGHZYdOheZ+LR+bQtw0KHs8dFt5pHuheZD1OjlpuaJcXqj5dkeBXHJch5mGgEXMPx9wQkfYf7f/oFNjMDKTmpgaQg/sWUAuRQVAuBfeuqG+CeVeRQe3FyathXDTwvmzyBd0cd/H5V47Pm7siBEUX6FrzRQHpPMhyK4Amx/60c3z0NWS063Wyg9ES/+Qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eXYAhY/HtL7puT9vPIIaaLMyQDKP1w0bPp0lsPFNNdQ=; b=CuLF0yQe/zN8Mka1VYuYNGw4o/pWWi0s/507q7BCMwDs/NvMULo38ySb0ttp/DdPHNy6mfbeO+GNWZ63E7M0JWwbJq2rBRdHghcVyWQB4wz7ibU7G9Mu6DEUHKpR8q42PaB5f862jnpHywnI/uMjGAMbCeS6jYvrQ6fPEYaFfb0= Received: from DM6PR11MB2555.namprd11.prod.outlook.com (2603:10b6:5:c5::33) by DM6PR11MB3099.namprd11.prod.outlook.com (2603:10b6:5:6c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Tue, 22 Sep 2020 10:26:47 +0000 Received: from DM6PR11MB2555.namprd11.prod.outlook.com ([fe80::59db:260c:93d9:2439]) by DM6PR11MB2555.namprd11.prod.outlook.com ([fe80::59db:260c:93d9:2439%5]) with mapi id 15.20.3391.026; Tue, 22 Sep 2020 10:26:47 +0000 From: "Power, Ciara" To: Honnappa Nagarahalli , Gaurav Singh , "dev@dpdk.org" CC: nd , nd Thread-Topic: [dpdk-dev] [PATCH] lib/metrics: fix memory leak Thread-Index: AQHWbaKHgZcQwpegSEuM32mfWmYZwKkzaeQAgEFPHAA= Date: Tue, 22 Sep 2020 10:26:46 +0000 Message-ID: References: <20200731034520.30791-1-gaurav1086@gmail.com> <20200808163906.8021-1-gaurav1086@gmail.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [37.228.239.233] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4940198d-2939-4fa5-1047-08d85ee20288 x-ms-traffictypediagnostic: DM6PR11MB3099: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3968; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4nXIyjOW6UzOiVvWlwdBBqXsWFjjPksiSiujJQNwhAAyEPFgDwvIk9cr2B5h10/bKWp5G5JJwfPX2ceI/M7m6yvNAviN8LGhp1AVKUfdFlD/b+MKfs6ZqB5LenNWpts6wmvNFFTLEOW2OyTIC3JPsufA7C3LhWSYMm/TtuabcC0GF9g6Dq0IrTetiOUN9ApgrTMP3e8m7mIdauBFfg8Bhe53SFqAHEqm+uX+bPANz519d7vNPETUv00HWbEFca9fhxvdy0T9x+fTtCelXH/8rpEqlabPGYthONZwBQIfPOCDI71q+3y/22u3N2Ld7JKq+Nu8Dx2cn0Psdbef5JPuIWo4fN7Kkl43quaYOBOIhdnGNaijGf2UPe5bOrkDN7u6a4+S1EHHON0CM59l4R7Z+A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB2555.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(136003)(39860400002)(8676002)(478600001)(86362001)(6506007)(316002)(83380400001)(4326008)(52536014)(55016002)(2906002)(33656002)(76116006)(5660300002)(8936002)(110136005)(66476007)(66946007)(9686003)(66446008)(64756008)(66556008)(7696005)(26005)(54906003)(186003)(966005)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: gIMxMqeyXxtsvkqFIyyeeh2VjYFjeHM5PdyRJLeCuD4FcilsTwDHugn4icbpgbQDcIj4/oPKWqNWdWS4Slx4ZXVKFNRy2MUFrYU6mfURssgjEFBuy6GEL3v1FY+wyxgpJruOS40Ts9hAIm349Hbdv0AfhtISOW+9TOApb9tAryMIDsq7xagY8U0KXXSAEinC/8PrboHUP+3RMK0i5tH/OBSYwHGmsclJ7xiQh2bFIvDdkSIiJYi8P0PIwv7vK5hN/rWrnN5hMxsBNLW7k3PG1xvqjBxV1wP+6MKu/J7NnFvFrhxAcaAj7HdyxLVQ37AH08hU/XTL4DOXX8h4bJgPEDFjwb8zUlOwsame1g14+2AluZmzD3iib9OMYwMFhXGpGxCfd9JxmNd8xjvlm+spO/9z6vW/VMfuF807fHL5i8+a4LNjzM+v8yQsdJZsth9aALK6XXTTF4jHBwHHd66dirVpMlVnOmQVRSXXetWN9Pl7bcUwu5r8a2rusjJTxSj8C32BzWp7alcc1Pd/5LZNeTmJ2++Qxhu9fuaxXDx7+ba+nDFdHy+lhhkKmyn3kHxxxQUHsfIL5DI2rJRmyFch1Wp8lZ6zWBKhknDn9Ib46fOjBq/saByrYSLQ6RCHe3zoKksgyvZtfpHLgI5eiDyBBw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB2555.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4940198d-2939-4fa5-1047-08d85ee20288 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2020 10:26:46.9617 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0NyD327lqxgohELUE8OSRSBAlAGZiUqLKa+s4JDHiiX45NOPd/HcHywbkZ9NBnC+LkXxeuUAPsUgIe3PUzfPOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3099 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] lib/metrics: fix memory leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Gaurav, >-----Original Message----- >From: dev On Behalf Of Honnappa Nagarahalli >Sent: Tuesday 11 August 2020 22:01 >To: Gaurav Singh ; dev@dpdk.org >Cc: nd ; Honnappa Nagarahalli >; nd >Subject: Re: [dpdk-dev] [PATCH] lib/metrics: fix memory leak > > > >> >> fix memory leak >> >> Fixes: c5b7197f66 ("telemetry: move some functions to metrics >> library") >> >> Signed-off-by: Gaurav Singh >> --- >> lib/librte_metrics/rte_metrics_telemetry.c | 21 ++++++++++++++++----- >> 1 file changed, 16 insertions(+), 5 deletions(-) I think this commit message should be more descriptive, and is missing Cc: = stable@dpdk.org >> diff --git a/lib/librte_metrics/rte_metrics_telemetry.c >> b/lib/librte_metrics/rte_metrics_telemetry.c >> index 289ebae0b..7b6d1063c 100644 >> --- a/lib/librte_metrics/rte_metrics_telemetry.c >> +++ b/lib/librte_metrics/rte_metrics_telemetry.c >> @@ -41,12 +41,17 @@ >> rte_metrics_tel_reg_port_ethdev_to_metrics(uint16_t >> port_id) >> } >> >> xstats_names =3D malloc(sizeof(*xstats_names) * num_xstats); >> + if (xstats_names =3D=3D NULL) { >> + METRICS_LOG_ERR("Failed to malloc memory for >> xstats_names"); >> + return -ENOMEM; >> + } >> + >> eth_xstats_names =3D malloc(sizeof(struct rte_eth_xstat_name) >> * num_xstats); >> - if (eth_xstats_names =3D=3D NULL || xstats_names =3D=3D NULL) { >> - METRICS_LOG_ERR("Failed to malloc memory for >> xstats_names"); >> - ret =3D -ENOMEM; >> - goto free_xstats; >> + if (eth_xstats_names =3D=3D NULL) { >> + METRICS_LOG_ERR("Failed to malloc memory for >> eth_xstats_names"); >> + free(xstats_names); >> + return -ENOMEM; >> } Is there a reason for the above changes? I think they are unrelated to=20 the memory leak this patch is fixing. >> if (rte_eth_xstats_get_names(port_id, >> @@ -167,9 +172,15 @@ rte_metrics_tel_format_port(uint32_t pid, json_t >> *ports, >> } >> >> metrics =3D malloc(sizeof(struct rte_metric_value) * num_metrics); >> + if (metrics =3D=3D NULL) { >> + METRICS_LOG_ERR("Cannot allocate memory"); >> + return -ENOMEM; >> + } >> + >> names =3D malloc(sizeof(struct rte_metric_name) * num_metrics); >> - if (metrics =3D=3D NULL || names =3D=3D NULL) { >> + if (names =3D=3D NULL) { >> METRICS_LOG_ERR("Cannot allocate memory"); >> + free(metrics); >> return -ENOMEM; >> } This does fix the resource leak, but I do think it can be done in a=20 simpler way, as shown in the patch I sent to fix the logged coverity issue for this: https://patchwork.dpdk.org/patch/78052/ I will remove my patch seeing as this patch is fixing the same thing. =20 Thanks, Ciara >> -- >> 2.17.1 > >Looks good. >Reviewed-by: Honnappa Nagarahalli