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 8CFCDA0518; Tue, 11 Aug 2020 23:01:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 92CCE1C023; Tue, 11 Aug 2020 23:01:36 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83]) by dpdk.org (Postfix) with ESMTP id 79CE61C01F for ; Tue, 11 Aug 2020 23:01:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rt5XfbQS0jr8IYKIgyU1iHrD/xykkyhUBLy0JzyKMlA=; b=6SlzIH1f1Ed7yNvs1zbeE0xW4HoNzhRgLhT0yFer18ZDCXYL90G5fB36xM2DQNuu74YcHHuofdNg8WOxfC3aVPabnnyk4xTgh/QNZnGOBLl1w4vfcbalkYvPGgq3SfzRGPfujCktxxboyQUFGLmzNqPtzwNQhCdc3d/iU8IYWtE= Received: from DB6PR0402CA0022.eurprd04.prod.outlook.com (2603:10a6:4:91::32) by PR3PR08MB5628.eurprd08.prod.outlook.com (2603:10a6:102:8e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.15; Tue, 11 Aug 2020 21:01:34 +0000 Received: from DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::a2) by DB6PR0402CA0022.outlook.office365.com (2603:10a6:4:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16 via Frontend Transport; Tue, 11 Aug 2020 21:01:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT035.mail.protection.outlook.com (10.152.20.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Tue, 11 Aug 2020 21:01:34 +0000 Received: ("Tessian outbound 195a290eb161:v64"); Tue, 11 Aug 2020 21:01:34 +0000 X-CR-MTA-TID: 64aa7808 Received: from 1e7f90de2071.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1A6A540C-E0DD-4F09-AB6D-18F48BCAF987.1; Tue, 11 Aug 2020 21:01:29 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1e7f90de2071.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Aug 2020 21:01:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L0/R0Gr51c531nq0OCGzJ6if+suDG2GiNA5brzxI36E1jWq2B5o/bSYlmFpRkYunRDcJvhczOE7pyCj/1uUIsNXjOnItOq+H9iSnvNhIcr2F6/EUGeGeon4J1fJyW64PT/QWsQfwO1ffvgYQrkPas8KOlShGvh3XH3alGq6AFCx0PBV3AgXiuzwNC6J+M7+Hy9a16lylsivQXYa/Ew4XpDQCKzu7bVKxNxJficxyr7Dp0jgGYtE1Fs+dIa7GjOMGLnB0ayOuiMcJHXvQZ0gcjwXAgnFtWMCuoSO+Pdsbuhxzyo2+aYcJADZ3iEboJzV2W3lXZbpgSgWfOXTRx7rFoA== 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=rt5XfbQS0jr8IYKIgyU1iHrD/xykkyhUBLy0JzyKMlA=; b=hdCucHt4QuP1fAaEW6razV6Ec+8QPSuItW222v4hlmvtbp3SCc33QdsZfKLU9/bBM6LiImVBHLertis2E6UtOBGkzBOebGAnmYpQ9YJuR0uL8Scz/NpAbRU00WgTimQYwvEVv7eOWf/qTR8ZcMuDTiDbT/ARKwbP00eZB6KpcfW6iMF6NhmrBGXSLPw2Z+Ax8z4AP40Q814JkhsQfsB+5yxk7geYp6/UqAuD3lfZwIKAJfskhWfZSB4vBLMc+660fcavdmJA97mXGvHWHhrl2JCI38PwtcEEcCjaMQwAHnYPejfXwTbb/KKTVaDhlHDaGaEkMgEgQ1gwW+fucZEsEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rt5XfbQS0jr8IYKIgyU1iHrD/xykkyhUBLy0JzyKMlA=; b=6SlzIH1f1Ed7yNvs1zbeE0xW4HoNzhRgLhT0yFer18ZDCXYL90G5fB36xM2DQNuu74YcHHuofdNg8WOxfC3aVPabnnyk4xTgh/QNZnGOBLl1w4vfcbalkYvPGgq3SfzRGPfujCktxxboyQUFGLmzNqPtzwNQhCdc3d/iU8IYWtE= Received: from VI1PR0802MB2447.eurprd08.prod.outlook.com (2603:10a6:800:af::16) by VE1PR08MB5742.eurprd08.prod.outlook.com (2603:10a6:800:1a9::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.17; Tue, 11 Aug 2020 21:01:28 +0000 Received: from VI1PR0802MB2447.eurprd08.prod.outlook.com ([fe80::d464:b0dd:5f2e:ccb]) by VI1PR0802MB2447.eurprd08.prod.outlook.com ([fe80::d464:b0dd:5f2e:ccb%5]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 21:01:28 +0000 From: Honnappa Nagarahalli To: Gaurav Singh , "dev@dpdk.org" CC: nd , Honnappa Nagarahalli , nd Thread-Topic: [dpdk-dev] [PATCH] lib/metrics: fix memory leak Thread-Index: AQHWbaKFu7K6wFTXXky9OXipvjP38KkzaNCQ Date: Tue, 11 Aug 2020 21:01:28 +0000 Message-ID: References: <20200731034520.30791-1-gaurav1086@gmail.com> <20200808163906.8021-1-gaurav1086@gmail.com> In-Reply-To: <20200808163906.8021-1-gaurav1086@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 76f49586-daa0-49e9-b142-1f9f37ea0653.0 x-checkrecipientchecked: true Authentication-Results-Original: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.112.90.121] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5192ae6d-fef9-4f64-510a-08d83e39bad0 x-ms-traffictypediagnostic: VE1PR08MB5742:|PR3PR08MB5628: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2331;OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: l3tMws9HkUGaBzNOZuf45uBxS57PL/BG4HnPv4PWbXWzXYj2DC6Aq6FNv/gYzGcXXcU9QfroRuo/+G95kkXKXvVslzku+XI9HThoFUORoJQ7Jn9tcnuBFOBT6OACMIWi6KjJdHNiTo8wiXQ4pn/CNE+3vb8aIk6To+TxFeE83BASuB1bFIJ3yJo4VWdpf0/iaafxQ4MBBbdAL9OjPli1OaNayTP2/et3sZ3w9jpsem5+FgOsdCT4dPdNv2sIWlhbh/X4d/szlfaKf9GBpXXXU8Kd3G/0U5zszxVep4vhcv+UEOWoZE9edA8zw73ERQarejW19V0vOyYi4OtU4HBOJQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0802MB2447.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(376002)(136003)(39860400002)(346002)(33656002)(186003)(6506007)(26005)(71200400001)(4326008)(83380400001)(7696005)(55016002)(8676002)(5660300002)(86362001)(2906002)(52536014)(54906003)(66946007)(478600001)(66476007)(76116006)(66446008)(9686003)(8936002)(110136005)(316002)(66556008)(64756008); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: yjqNRpQFvjHEzpg6SCZfTOpq1C4AfmVadzJUqZmQ+/YUbO+zDm1BvVTkxzllyx3M5AX2OtI5ufiaX64Bf7CXSVe47mQqB2Yw2+rzvVkcEWamcyTlSnKMLh3PaYyrCvPqiVJLwUIIUAPHbKVebTOSKv2zATECN2Ljy4tkHDDarFHK4L+zbCW6EOozFlYC2SsDtWq17sEClXs+36rb7oFexYjXG0AkUhIFM/oU405Sn7rWVVY4Lj/Ozpr+btcPnqEK+BK4pgZF0+P5h5Wyr2V589+NpEXm0EAx0yGsy8HJ9QZKQ0e8Dt/sqIGz7EdeFZdiP2m4XnAQExGqKp0KCLA6ia0JBnCk6YHuKEjRv1VPzYHAwOXYrYRBoQjkWQ703S3nsSxgG4tQVdxCGAoeMTS1fypTH7hGCRDSz5oHsGwjB0njz/dNvOHq35/spql5fDsvweVpZh1vClSY8V0UqSVV5gOVbqrnRcgXm7a0qediIYBBakUM1fW8s11Q63nYDGq/XAFU6BAendvNnbpjFdDHOoc0xnJHq8mpCSSF0Gc7K/cnQhdRJ2jldIoYbklLZZHgthDb4H7WlE5nU0RTokd+Q/WPrpL6yQHMa6Cl6L3fhQuocFL4Wl30W5jCsqrBZp9v54Un8TQU/vttSVld8XIQcw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5742 Original-Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c28a2d95-f425-43a3-27cd-08d83e39b73f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IIvtgRpwxKNRxVz1CJ5nGnU3dRjJBjXqzciA3+u2EymXD4Ykfij8XgHlgZiv4YaM9vXa295hcHMLAND56REHkcTdUA9/TIn4hngpkbgl0CVCB1YbDEpISywuBdu2QzgVr24fYIvfQxBLRz91iKB+QhoG7iEq2D2HByofEviv4vhg9obZQNDDNYwW66MUvHA62ZBGgpgOijCTBHIIeE6F6UpKpcotMHFSn7yYT7G9qUhU8OOxJVGuUebb5+V7AGzVWL4dYE3If7YXW5QOnPXnYbRJp93wZ2sW2/15oSzTh+tki+oNyir+0HfPQvX+YRxD+JM6lF1je+F5sQBdwEWqjtKKq7xRGsnteCEL6Je9TGR8hR8JuIuQ0kfNLR/Kk5kAhqfi/CvINaDhuGWuUKtYOw== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(136003)(39850400004)(346002)(376002)(396003)(46966005)(8676002)(316002)(8936002)(47076004)(336012)(83380400001)(54906003)(81166007)(110136005)(7696005)(70586007)(478600001)(82740400003)(70206006)(82310400002)(356005)(186003)(2906002)(26005)(52536014)(5660300002)(33656002)(4326008)(9686003)(55016002)(86362001)(6506007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2020 21:01:34.1137 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5192ae6d-fef9-4f64-510a-08d83e39bad0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5628 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" >=20 > fix memory leak >=20 > Fixes: c5b7197f66 ("telemetry: move some functions to metrics library") >=20 > Signed-off-by: Gaurav Singh > --- > lib/librte_metrics/rte_metrics_telemetry.c | 21 ++++++++++++++++----- > 1 file changed, 16 insertions(+), 5 deletions(-) >=20 > 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) > } >=20 > 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; > } >=20 > if (rte_eth_xstats_get_names(port_id, > @@ -167,9 +172,15 @@ rte_metrics_tel_format_port(uint32_t pid, json_t > *ports, > } >=20 > 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; > } >=20 > -- > 2.17.1 Looks good. Reviewed-by: Honnappa Nagarahalli