From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D969A00C5; Wed, 2 Feb 2022 08:48:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA20640E03; Wed, 2 Feb 2022 08:48:21 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 510C340DF4 for ; Wed, 2 Feb 2022 08:48:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643788100; x=1675324100; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=nu9Uw55LYHqUX+CC4TjPK6UUHY7zL8yNLoq/G3tjqWY=; b=jyJ1UNoNzL6Y2NmOC6cYDwegXJUHHoVtIQY2mm45dnk9Fam8p1i9QfpD yQ5lgQX7ulUp6AhZS6WY8ffhXz3zotOvolDHxRo4zOTmbtxxAC6tAHv2f JXcYlajEawZqGVjmoX1hVRCQpYGedffuA4Xy6w//Pbra7k2HiwFG0BUPf uxikjflowYX4VmlAH2GtGL1HcmnNnSN9paHTKctpb5U2zqPSOPnp8JKAt MVlOOliyygoM7arXnm0A/QEVbz7WRi+K2qVRM7PBdOMddmDEyRmKkNZ+g brUeNIiuPJ6/OPm3A3sxyr4oCGQLsQrWdWxgyBnNTZHVcOWeriuJ3yhZ9 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10245"; a="311175587" X-IronPort-AV: E=Sophos;i="5.88,336,1635231600"; d="scan'208";a="311175587" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2022 23:48:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,336,1635231600"; d="scan'208";a="534774454" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga007.fm.intel.com with ESMTP; 01 Feb 2022 23:48:19 -0800 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 1 Feb 2022 23:48:18 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Tue, 1 Feb 2022 23:48:18 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.46) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Tue, 1 Feb 2022 23:48:18 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nLaPHzSA28XP3/LkBbBOELiK5IyAsUMG+MpmcS8SGw0SZwWMAojY68tpKGVnfFov6uo8ekXMXF/PPEQ6OT490F3LgMBq/oK9pSTbxfXbBPxfLytCsC16iiWhhD/aFK6OgvDnNE49dvu7koTDmzVK6085RnH/YDNMkVpR58xVDY5ATTm5kDvIZofyxZ8g+/O88H2JStW9FMLGB4+QKk1UN1k5I8XIAnPt0KSmdinDrxegAlXst3LbzvmKJypnCcWbjNOZz8beZSh0OqWusqf86/OV88sZSmR2AU9V98NvXopr/VwxPGy5zfjsrGlGsNCR/6BXYBo6AE7UMx4OtI+7QA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qcuUz+jOolRKfNE5LjLS0ZKkpysKZ9Psr+DcLl4Uz/U=; b=U/T6yJcVKHgS2KCaAom6GyUs6dSUMK+ols4hAfo/sx+L1qAweEO5KhypeN/SMuxMBCosLf+/Xmzoopiieb0+3ytc/0GoWN9Z5JRTbKdpSoo2FpWH1v171Wqp0gVi7+PRTOHMfxcd/R4uHRnEBq542NDz9T22xTY4e+8LwcqsK1veEgqdRVDktA9Ie9qG+myH2HFjpHHgdO4uugGm8rS7v5509Tg6t0e68DbWNwWHvYR4r4sYBoywt7fqDio2SYJEIU6jCZ/EU7qXd0GGV2iqsX1PT31P46bx/PVYr2aOYuajkEaa9Prn0hqG7HcbhxgjRhk9UcWtPf6ngZEmQAqEvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MW4PR11MB5911.namprd11.prod.outlook.com (2603:10b6:303:16b::16) by DM6PR11MB4169.namprd11.prod.outlook.com (2603:10b6:5:19b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Wed, 2 Feb 2022 07:48:16 +0000 Received: from MW4PR11MB5911.namprd11.prod.outlook.com ([fe80::e00c:1274:42e2:8355]) by MW4PR11MB5911.namprd11.prod.outlook.com ([fe80::e00c:1274:42e2:8355%7]) with mapi id 15.20.4930.021; Wed, 2 Feb 2022 07:48:15 +0000 From: "Kundapura, Ganapati" To: Weiguo Li , "Jayatheerthan, Jay" CC: "Naga Harish K, S V" , "dev@dpdk.org" Subject: RE: [PATCH v2] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Topic: [PATCH v2] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Index: AQHYGAg/1XAe+kVUJUiapfICqeBpRKx/4h2w Date: Wed, 2 Feb 2022 07:48:15 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.200.16 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 40360ed2-4f7d-4719-1c9c-08d9e6205f24 x-ms-traffictypediagnostic: DM6PR11MB4169:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:88; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nOPorBwj05Od+o3gIJgAMDgFZhq6H3tp8oM7f6ofZ5sMLIxJD4cK0j9G4Qe9IBccNIxUR9s5A4rGsq53xwRJl5Gp/isoGD2GnSUf3n671bgttwHzOckHo79ub5LcvTdp+SKT5SYq3VsWWBsv3Nurz1i1VB9eapYk5HU1JKY8QKEaa6hnnXgx1dYxx7VmjWBsf4jj7Thi7lTSPrHdpOZi3g5/F4RsjrCjNIIN/G+BX4jn8gO8IWJU8Vi4eczMZmgT05ZucrMjUOkzx1UYvWRjVjxdh3wBIDF4YuxLUuzG8kYQR2Hb8YFljKELkzW4fUzhvhrz/3LzBshgoor07NQglxFXMemsFOTMyv/UEmymoUT8Q2nQCSC6GMTUh3nEhsOsW2YPLt9CQ8+7Eibse4i5+Ige95NvHc6vJKzccbphj92SuxjuWQA7XaAAo1hFH/1PS6YkCFskxccaS8oZRiAr6EY6oD6bjEpo7UkmbpUOHc3rHBYcGDL+3At/YC5JzER7CkJ1v4O23jAwkDaml+/ntG6COVjhtLUJqJRjeuz3c1XCvexXUgmFvAtRiW/YhuxdFl6N+vlqbUK2HkCFe9gGMACi7+1fte0+uaL+9n+N5M0zB1NegwuKL2y3tkXTyQs80iOzpWHkrE+c9whRZtxKwC7TV2q1xk198W9i1ubk+dXmrMpX4aXqYyQlAlxIaC5LIFebfn1g6MdovVknBrT1BQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR11MB5911.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(8936002)(76116006)(186003)(55236004)(53546011)(4326008)(8676002)(66446008)(38070700005)(64756008)(66476007)(7696005)(66946007)(9686003)(66556008)(38100700002)(6506007)(26005)(316002)(6636002)(33656002)(86362001)(82960400001)(54906003)(52536014)(508600001)(110136005)(71200400001)(5660300002)(2906002)(122000001)(55016003)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?WFwWNxAiweiZ/w53RafOLYSe46q5MEYVZNtyznrfUPE9xhbXuojBSa40uj0V?= =?us-ascii?Q?V9c2C7BIYToRVpdoBeqLmOVIej/Yx6cgRehay/VpUqZcdu51RV2J1o7k4wtt?= =?us-ascii?Q?vzUStkSZf2MsTi8FSvvLz6w+hB5rszi5YaaCgtPpvHG0M2JOjmQuFKxeTeOH?= =?us-ascii?Q?8Mge/UdwX9Geup/6EQGRZN6Q0fa/7LQMi/+2JWjasvnEW1ixYGNHkrxbZ4Jk?= =?us-ascii?Q?nMdk/eRIKiX5oxduE++3Srh1tTjpvpzzuSIdsy/0/5Hv+8/LIQNHvbzDIdMA?= =?us-ascii?Q?bBJbd4RCLWEBdnbOgFXbSIbxO7qRGOvA8rMraZh0z/YCRlxy57WrxtmAMc+w?= =?us-ascii?Q?vkvcrcvkefpFum8A1IjUuvHPqC8S8yJMPDS7fZj/8ISGGw6aCnm4hN5b4ZKW?= =?us-ascii?Q?fq/j41GOmmOHt274PvNx9cJ1pmFgFLuamaGV9ZLCxVHpopnXJ8hUilevLmwg?= =?us-ascii?Q?Ng3Pnn/zYUdkpnSCbIbJmmSK0hc+v50OEdkFERTo3As3CJnDWkgVOvCdT4NO?= =?us-ascii?Q?EBMOstpFOJMratQjurePsS6G+eQzH+NK57IxG1A6/R6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ZWGKS4WFhlk9U4DTkZV7mP0ekIRlI+PjqSXG8BxE0qWt5S?= =?us-ascii?Q?wAnpqYgSDg0kzfcUt6GUxMMQ0RzcTWH32vP11ziKY0ObShSwnXMQ6/FmZd7j?= =?us-ascii?Q?8kBXxxHRqbf144N6KbYHOD2e7fv6QXAENlptqHxLRKtvYX1zAx+zuwSThc4k?= =?us-ascii?Q?hvgZDo+HEWJvgokPacWDvJTkdXE8usU6zYztdF4eyFNY2tW2vsgyPWDVWb71?= =?us-ascii?Q?F6k7kQ=3D=3D?= 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: MW4PR11MB5911.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40360ed2-4f7d-4719-1c9c-08d9e6205f24 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2022 07:48:15.7617 (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: Ua9iQlhd5TgAUKuQHva0Lr1Bc2bc5MMW4+Tr5qbnqxmE45KHzDZCgWCqX65FPcV9b0q+O59TZR5PcrpOEN0xxyTwKGfNwZSjtel8RPfXDdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4169 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Acked-by: Ganapati Kundapura > -----Original Message----- > From: Weiguo Li > Sent: 02 February 2022 13:11 > To: Jayatheerthan, Jay > Cc: Kundapura, Ganapati ; Naga Harish K, S > V ; dev@dpdk.org > Subject: [PATCH v2] eventdev/eth_rx: fix memory leak when token parsing > finished >=20 > The memory get from strdup should be freed when parameter parsing > finished, and also should be freed when error occurs. >=20 > Fixes: 814d01709328 ("eventdev/eth_rx: support telemetry") > Fixes: 9e583185318f ("eventdev/eth_rx: support telemetry") >=20 > Signed-off-by: Weiguo Li > --- > v2: > * add memory check after strdup > --- > lib/eventdev/rte_event_eth_rx_adapter.c | 45 ++++++++++++++++++------ > - > 1 file changed, 33 insertions(+), 12 deletions(-) >=20 > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c > b/lib/eventdev/rte_event_eth_rx_adapter.c > index ae1e260c08..8519c98b19 100644 > --- a/lib/eventdev/rte_event_eth_rx_adapter.c > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c > @@ -3332,26 +3332,31 @@ handle_rxa_get_queue_conf(const char *cmd > __rte_unused, >=20 > /* Get Rx adapter ID from parameter string */ > l_params =3D strdup(params); > + if (l_params =3D=3D NULL) > + return -ENOMEM; > token =3D strtok(l_params, ","); > rx_adapter_id =3D strtoul(token, NULL, 10); >=20 > RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter > _id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get device ID from parameter string */ > eth_dev_id =3D strtoul(token, NULL, 10); > RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get Rx queue ID from parameter string */ > rx_queue_id =3D strtoul(token, NULL, 10); > if (rx_queue_id >=3D rte_eth_devices[eth_dev_id].data- > >nb_rx_queues) { > RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", > rx_queue_id); > + free(l_params); > return -EINVAL; > } >=20 > @@ -3359,6 +3364,8 @@ handle_rxa_get_queue_conf(const char *cmd > __rte_unused, > if (token !=3D NULL) > RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" > " telemetry command, ignoring"); > + /* Parsing parameter finished */ > + free(l_params); >=20 > if (rte_event_eth_rx_adapter_queue_conf_get(rx_adapter_id, > eth_dev_id, > rx_queue_id, > &queue_conf)) { > @@ -3396,26 +3403,31 @@ handle_rxa_get_queue_stats(const char *cmd > __rte_unused, >=20 > /* Get Rx adapter ID from parameter string */ > l_params =3D strdup(params); > + if (l_params =3D=3D NULL) > + return -ENOMEM; > token =3D strtok(l_params, ","); > rx_adapter_id =3D strtoul(token, NULL, 10); >=20 > RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter > _id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get device ID from parameter string */ > eth_dev_id =3D strtoul(token, NULL, 10); > RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get Rx queue ID from parameter string */ > rx_queue_id =3D strtoul(token, NULL, 10); > if (rx_queue_id >=3D rte_eth_devices[eth_dev_id].data- > >nb_rx_queues) { > RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", > rx_queue_id); > + free(l_params); > return -EINVAL; > } >=20 > @@ -3423,6 +3435,8 @@ handle_rxa_get_queue_stats(const char *cmd > __rte_unused, > if (token !=3D NULL) > RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" > " telemetry command, ignoring"); > + /* Parsing parameter finished */ > + free(l_params); >=20 > if (rte_event_eth_rx_adapter_queue_stats_get(rx_adapter_id, > eth_dev_id, > rx_queue_id, &q_stats)) { > @@ -3458,26 +3472,31 @@ handle_rxa_queue_stats_reset(const char *cmd > __rte_unused, >=20 > /* Get Rx adapter ID from parameter string */ > l_params =3D strdup(params); > + if (l_params =3D=3D NULL) > + return -ENOMEM; > token =3D strtok(l_params, ","); > rx_adapter_id =3D strtoul(token, NULL, 10); >=20 > RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter > _id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get device ID from parameter string */ > eth_dev_id =3D strtoul(token, NULL, 10); > RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > + if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) { > + free(l_params); > return -1; > - > + } > /* Get Rx queue ID from parameter string */ > rx_queue_id =3D strtoul(token, NULL, 10); > if (rx_queue_id >=3D rte_eth_devices[eth_dev_id].data- > >nb_rx_queues) { > RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", > rx_queue_id); > + free(l_params); > return -EINVAL; > } >=20 > @@ -3485,6 +3504,8 @@ handle_rxa_queue_stats_reset(const char *cmd > __rte_unused, > if (token !=3D NULL) > RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" > " telemetry command, ignoring"); > + /* Parsing parameter finished */ > + free(l_params); >=20 > if (rte_event_eth_rx_adapter_queue_stats_reset(rx_adapter_id, > eth_dev_id, > -- > 2.25.1