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 E622EA00C2; Fri, 4 Feb 2022 07:55:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 760B940143; Fri, 4 Feb 2022 07:55:16 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 66A5F40140 for ; Fri, 4 Feb 2022 07:55:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643957714; x=1675493714; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0SlzVBdvlqManXmxY4bWVIZUQT63RSc+cKBDtMM3DOc=; b=crXaLbW0K3Y+Ign6wa4SO//QAboGFt9abU/3Evkw5BJN3MxnKDkoHivK qdAHEfHZJcRLR0g+A54gTUylxwv/8bVLFReBkwg6WLmUrgo8MXJjkFqVq yAlkeAVND0QTfvPbFbMXVZgMpYX8yDfj7DYnAnEWcP7h9UeYjXMjivMv2 8H0c+4Kdar+UfZd7jjN1CYxMudB1eA3sCxYwlsa2ZcNi2d7m6uzNrBJMB TzzULLqYZJdWG7OdZmeDcYQP6OkbR8Si6d9CFVl6u5biY3lemRSIJWlmC MlHeq21uT3RltcLcXDlZCwUKZ34E+LYwtpEPG8m7kk9VYRoLMjmfBBSHc g==; X-IronPort-AV: E=McAfee;i="6200,9189,10247"; a="248533652" X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="248533652" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 22:54:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="627695574" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga002.fm.intel.com with ESMTP; 03 Feb 2022 22:54:57 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 3 Feb 2022 22:54:57 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Thu, 3 Feb 2022 22:54:57 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.107) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Thu, 3 Feb 2022 22:54:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eme2wyCjGYqPdUcuFxWsc9pbdw93kFdQg0IVxcEPSu8p96gl6mioDT8ScCM491J0ziiD5r3FXJ5G3pklP6r0Y1FxfXui09K7Qm6sYaurNvG0ENEVxAhC7hmm3UL2YRGn895jvnd0FKrB7xJqBP7rE3WuPLoDnV+sOiprOv02XvV2Aar8OrO798JekHSnO0w6H/wHbkFg2TcNC/1Z/y9FHVSowYajaz/22VxeWsa6BYSLNSUnF7PixhDPLwdNs+XUoBfzKZyM7QA1Rwh7Ay8TCewUg2C8fb0E4XhQ1EbkQPJJ6+X9BlSvwN15+4GPyVr8UF0MXYyCp6b4E/wIj5Hkug== 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=5wKmVqQhZ8RMc7lYsGu3sRMYhgnU0mmml8BSaKbGVec=; b=P9s9LDNkYjSHuWtd/60+YeG+nMCcWi7ai6F0aZZHoZxd3RSlLkefphOp2wJJQ0Ojsm94/eMj+3oyAKUH3qoGUk9ZeO1UoEgLFdcDfWQJloocDME5SrXWeyEMK+OtHHkzHORzAlICWVju6rLx0Fk2QiSlnO2BaCSjEXfLIXpRjbKZ1WKAXwRBrPuTKl+01EfgtJreLhwkW9UXNb5e/UqKLC3H/AZn5qKK6T1/Q8uPNyDIUpEzTfm3UdS3cw/LvMA+0fimzDfb3AvCSk9h7becRBax3bE1O9LRZRxd0oKKRMmGIZET3KB/Wczq2KGRmEust4LAJ/uxuucjYkNw0LQcmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DM6PR11MB4348.namprd11.prod.outlook.com (2603:10b6:5:1db::18) by CY4PR11MB1334.namprd11.prod.outlook.com (2603:10b6:903:2e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.18; Fri, 4 Feb 2022 06:54:55 +0000 Received: from DM6PR11MB4348.namprd11.prod.outlook.com ([fe80::b913:f8f9:e5b8:ba88]) by DM6PR11MB4348.namprd11.prod.outlook.com ([fe80::b913:f8f9:e5b8:ba88%6]) with mapi id 15.20.4930.022; Fri, 4 Feb 2022 06:54:55 +0000 From: "Jayatheerthan, Jay" To: Weiguo Li CC: "Kundapura, Ganapati" , "Naga Harish K, S V" , "dev@dpdk.org" Subject: RE: [PATCH v4] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Topic: [PATCH v4] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Index: AQHYGNscGJocc4w9gk21EPajDr5xY6yC9hbA Date: Fri, 4 Feb 2022 06:54:54 +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: dd64a9d6-8d5d-470f-a283-08d9e7ab401e x-ms-traffictypediagnostic: CY4PR11MB1334:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:457; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EOtSfh5B4yVU0qXOPTGEYhcufW7SDh41Rrlm/OvtIRgImUZeIEimC26XAlv+0mwb0+cpjQVchWDqFTZAZRJW+rhRJknZvz9ctG/pIpwSAZWpxYH/NVnHmdmBPAJv7eB4IcLR5/m89iB+OnwTHOgEn4Sj6yIelY+I69Licaxu7G6+5WMjCApT9ewihJgNeMODLFsWGimNXa1TzV+c0jOHpLHD8k8feArOFO/RFsU5BBI4chHRPuoN1+RLjvJa1AikGWy4+DrfY+Wj1YRxmpPNrx13YQcCKWKV8w6axnYbRzpL77VoZyVmBCcZhc3Lompn6j+KtHLjHRNqLaZVYN91fLmzyLz9H+A9GQskSPIehXlUF/L2X139M7zk5Rz6JahQG5WDdzzeK4yXs04Lklq6OSCQeyYLvq4oLzNMfamwQ3vSw4x/EsIsKTYTcFEKTBu7Zx7fJazfC7itYonqBAb23bqkWPiLVoqBGoSfiZEJLGHZceGXOJgLS2tvhIX5tqnnocdpbVD0DB33l7fNEUJGZl4LrH+pHh9X+ZWTB1KX9CLx7jbge9vjLwc+Zgx2AyTsxDWi2R512mGSiWRYsjxozPM+raJ9cFbf3LT4M4q+euYkjBbfQxbQlnizSyqyQ7LMGQM0aXS86BZuI7X2rV0/maz5ChhSxgSMxWnPRm6+EvBpJfA+xyb7XyUj5DdG25HrlEMDIZyIA8VFbgeeWpLaUw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4348.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(53546011)(5660300002)(26005)(186003)(2906002)(38070700005)(38100700002)(6916009)(83380400001)(54906003)(508600001)(4326008)(82960400001)(66556008)(71200400001)(66946007)(76116006)(66446008)(122000001)(316002)(86362001)(8676002)(8936002)(9686003)(7696005)(33656002)(52536014)(6506007)(55016003)(66476007)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?zatVIzMBcldg/c7NZOWDVJCLyzwp1Bm+qjA8FILQa7TYc+jhhh1uWo/KwYBf?= =?us-ascii?Q?A9Yrl00kA+VGK9MnSNQ1BNE9XKA9hc7MaMBFFJnrpweLl5SlMB02n9SPio1k?= =?us-ascii?Q?/dQb6B5FqA7cL3Z115Hw0GY3dmO1aIoIBaLSQ3xUMVCDwjeKMROak1ZdllOF?= =?us-ascii?Q?YUzjC7rMDnmpVnx1SMoSTMW/wDB4hfz3jFTNUDnQPfUI47IBrcGgZ9xcLiYX?= =?us-ascii?Q?hMSjFq7VJvgmM0iJUHucj3ONxMEo5ORtAmp3FDR9QglG0T1xIQX6v1ZIbn13?= =?us-ascii?Q?SEOBjchIPsi7P4MVaZOCNM9xXRgxuTJjop06zCBt6Hm4LatGbNt6XhGAUECL?= =?us-ascii?Q?LFxE0WhYf8cCOatCMlfmd8ZE6L/ckpHQty9OIjSLjTnK1TC6Cu1McJq1d2wV?= =?us-ascii?Q?gHllkhLrTuy5K+WsPpGtM5AE4/sgtlgatzwGcfXkbi5C3N/Exdp5pSETFhww?= =?us-ascii?Q?37HhC4bqPoUlVvj/3pta4orAxpnWCXjTGkXJpfzcoWiusYOrQs56u36wL1PC?= =?us-ascii?Q?Ek8ebFXo3lSyRe/N9U1xwAa+5TtSLUoBmzAaqKJQPaEcnJXNH/5iOVAIENBE?= =?us-ascii?Q?FjB7QxCj2M3ZQxcnqcyG9w84jJlGRqIrSfHfIhKpR+wXVMQqBdwgKaw66fAL?= =?us-ascii?Q?UW5KrgtN/u50kanJppbXm3F5GF6neMM+7PkHK/EtE5a5nFybmDclWAWojltT?= =?us-ascii?Q?Ejjcu0gA+5If5grH1Q+QV5fmSFlzMzRDhRzjVGnAB9zx7BdeheBybWq3k61h?= =?us-ascii?Q?z0S4t851Ul5rc2+rOhmdkIteQkxuxxaPjC4qG/GVe4NY7I3W1KaAGbYR8Fh4?= =?us-ascii?Q?wAmIjuUfba2499D9kXawdeqRz7qZmk+9gSTlW4X27mKNHg+OwOchz5g8jpYy?= =?us-ascii?Q?4BsXYGpRytnfcD0KOa8SFpDLqlBYvwGcC2UktkRRU4ffzLuj3Ui/stkAa8Df?= =?us-ascii?Q?Q1awNUARwoP94co0yZsxXpylKts1kDOPSCO7caiaLwrMVYpNWpWBmsx6NzPs?= =?us-ascii?Q?cPS6LFLBb62I62Lu53lF6Cy937e2v3I8m+37746AM2i2wowYsIscp3gWUpR/?= =?us-ascii?Q?hOnsJj+BbnjGgOLSXpPiDfReTWSV2NlOgVzv/5sLcQ+foqygKyPjQlf66u3p?= =?us-ascii?Q?U8U4PIRXMbmHuQcP8ciI6p4UXmAWdA+2x+z/ceyXI/JNg8DDYMWODecXmuWK?= =?us-ascii?Q?zlxFJlatyDqtp6qiexfa6Ifdl8FKxi2DLnr1v8GJ8SxwFfjueDAqp3eND/gC?= =?us-ascii?Q?SOEnXIEhyEa5Z6SMy82E8XgFRpkwqa6/J9dW7J4sUnRY6T7oLf8+zY/xXPOo?= =?us-ascii?Q?vyqVhvY1SBw8CXn0DyO/G9gDfeHgxS3bTv1bexXI1iiHaqRz9v9YRL+IiIyK?= =?us-ascii?Q?a8jvEDlhGxImvGBy6+rdFVjQeuy7jHyVxtCnSdsTcsoczAJsSQ3qhn21JRpd?= =?us-ascii?Q?+LLNx5tEA18s/r5PFdRrNmCBIHQPyLqgc4lrjxQ5msxteCb0ivNAVXH9lyYR?= =?us-ascii?Q?krvKlbLlVkPI7h5qvjfQQ4bgXmATMwtyF8N7PnmgFWB5tPqHKLbQZmjJtIuT?= =?us-ascii?Q?d41C+jpJRkf4EcN3KTFnJ6aI4SRfqrcMbIlXUcGe7FXPrkb0vG3eBZ9y1MdR?= =?us-ascii?Q?0UED2VOh76zY7IdnOhosjmrbU7tDZo33+kCcp2LJ0I4YqkY0KekM1drfX677?= =?us-ascii?Q?uL7pww=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: DM6PR11MB4348.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd64a9d6-8d5d-470f-a283-08d9e7ab401e X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2022 06:54:54.9871 (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: gK4Za6PwfjAPR+YVfMbeFcU3hwsaltJHqpqMo/8y+VXID9tkX+LAHoD66q+AlNQG+JAu++MTz7+cRCpv9SHmFicR+b3v1oNQHT7GJ1pgk38= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1334 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 Hi Weiguo, > -----Original Message----- > From: Weiguo Li > Sent: Thursday, February 3, 2022 2:20 PM > To: Jayatheerthan, Jay > Cc: Kundapura, Ganapati ; Naga Harish K, S = V ; dev@dpdk.org > Subject: [PATCH v4] eventdev/eth_rx: fix memory leak when token parsing f= inished >=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 >=20 > --- > v4: > * fix compilation issue > v3: > * validate "eth_dev_id" by rte_eth_dev_is_valid_port() > as Ganapati's comment. > * validate "token" by macros to reduce code redundancy. > * use new macros to avoid bypassing the freeing of memory problem. > v2: > * add memory check after strdup > --- > lib/eventdev/rte_event_eth_rx_adapter.c | 90 +++++++++++++++++++------ > 1 file changed, 69 insertions(+), 21 deletions(-) >=20 > diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_e= vent_eth_rx_adapter.c > index ae1e260c08..de96dbf481 100644 > --- a/lib/eventdev/rte_event_eth_rx_adapter.c > +++ b/lib/eventdev/rte_event_eth_rx_adapter.c > @@ -293,6 +293,30 @@ rxa_event_buf_get(struct event_eth_rx_adapter *rx_ad= apter, uint16_t eth_dev_id, > } \ > } while (0) >=20 > +#define RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(id, retval) do= { \ > + if (!rxa_validate_id(id)) { \ > + RTE_EDEV_LOG_ERR("Invalid eth Rx adapter id =3D %d\n", id); \ > + ret =3D retval; \ > + goto error; \ > + } \ > +} while (0) > + > +#define RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, retv= al) do { \ > + if ((token) =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) = { \ > + RTE_EDEV_LOG_ERR("Invalid eth Rx adapter token\n"); \ > + ret =3D retval; \ > + goto error; \ > + } \ > +} while (0) > + > +#define RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(port_id, retval) do { \ > + if (!rte_eth_dev_is_valid_port(port_id)) { \ > + RTE_ETHDEV_LOG(ERR, "Invalid port_id=3D%u\n", port_id); \ > + ret =3D retval; \ > + goto error; \ > + } \ > +} while (0) > + > static inline int > rxa_sw_adapter_queue_count(struct event_eth_rx_adapter *rx_adapter) > { > @@ -3323,7 +3347,7 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unu= sed, > { > uint8_t rx_adapter_id; > uint16_t rx_queue_id; > - int eth_dev_id; > + int eth_dev_id, ret =3D -1; > char *token, *l_params; > struct rte_event_eth_rx_adapter_queue_conf queue_conf; >=20 > @@ -3332,26 +3356,28 @@ handle_rxa_get_queue_conf(const char *cmd __rte_u= nused, >=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, ","); > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); > rx_adapter_id =3D strtoul(token, NULL, 10); > - RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL); > + RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(rx_adapter_id, -EINVA= L); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); > + RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); could set ret and goto error. > return -EINVAL; > } >=20 > @@ -3359,6 +3385,8 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unu= sed, > 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)) { > @@ -3378,6 +3406,10 @@ handle_rxa_get_queue_conf(const char *cmd __rte_un= used, > RXA_ADD_DICT(queue_conf.ev, flow_id); >=20 > return 0; > + > +error: > + free(l_params); > + return ret; > } >=20 > static int > @@ -3387,7 +3419,7 @@ handle_rxa_get_queue_stats(const char *cmd __rte_un= used, > { > uint8_t rx_adapter_id; > uint16_t rx_queue_id; > - int eth_dev_id; > + int eth_dev_id, ret =3D -1; > char *token, *l_params; > struct rte_event_eth_rx_adapter_queue_stats q_stats; >=20 > @@ -3396,26 +3428,28 @@ 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, ","); > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); > rx_adapter_id =3D strtoul(token, NULL, 10); > - RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL); > + RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(rx_adapter_id, -EINVA= L); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); > + RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); same as above. > return -EINVAL; > } >=20 > @@ -3423,6 +3457,8 @@ handle_rxa_get_queue_stats(const char *cmd __rte_un= used, > 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)) { > @@ -3441,6 +3477,10 @@ handle_rxa_get_queue_stats(const char *cmd __rte_u= nused, > RXA_ADD_DICT(q_stats, rx_dropped); >=20 > return 0; > + > +error: > + free(l_params); > + return ret; > } >=20 > static int > @@ -3450,7 +3490,7 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_= unused, > { > uint8_t rx_adapter_id; > uint16_t rx_queue_id; > - int eth_dev_id; > + int eth_dev_id, ret =3D -1; > char *token, *l_params; >=20 > if (params =3D=3D NULL || strlen(params) =3D=3D 0 || !isdigit(*params)) > @@ -3458,26 +3498,28 @@ handle_rxa_queue_stats_reset(const char *cmd __rt= e_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, ","); > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); > rx_adapter_id =3D strtoul(token, NULL, 10); > - RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(rx_adapter_id, -EINVAL); > + RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(rx_adapter_id, -EINVA= L); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); > + RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL); >=20 > token =3D strtok(NULL, ","); > - if (token =3D=3D NULL || strlen(token) =3D=3D 0 || !isdigit(*token)) > - return -1; > + RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1); >=20 > /* 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); same as above. > return -EINVAL; > } >=20 > @@ -3485,6 +3527,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, > @@ -3494,6 +3538,10 @@ handle_rxa_queue_stats_reset(const char *cmd __rte= _unused, > } >=20 > return 0; > + > +error: > + free(l_params); > + return ret; > } >=20 > RTE_INIT(rxa_init_telemetry) > -- > 2.25.1