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 3C88FA034D; Fri, 4 Feb 2022 10:47:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4D8740143; Fri, 4 Feb 2022 10:47:41 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 1EF3540140 for ; Fri, 4 Feb 2022 10:47:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643968059; x=1675504059; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=xxepAMnw2Mo1zRb0rwG8GdgAQQm9Ii7+GFp40TrZmlI=; b=EBbFJauM69Wz+5igJSLpoyYJKVRqcsPJI1E/9d+5ev1eJ8AXkgcj+FHh f1IAYkdX38P+d0yW202tqqkfzg7Ba27tVC1gF05UVyQchFI61Lp5vh6K5 a3PpAm68JSoKaT2RTO8GTzN5YeXroWk2QOyDlL1XeTI1zQ63UBr2PzyN/ sgPIpBAHeYIASw0bfaZJSoHo3AE1+qppzOj4c/WtNQhsfUkNH2Ciophcp 7L1gTWrQ4l6Yt3Y2J/qyvMy645sTxCJJJXGk7YS7hn9aOhxHC1utFG8S5 slTg9cH3GFJLpSax9nUzeNOAqw+YPrPlZybXQuckwWPIekuPL1C+TkxO+ Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10247"; a="334735884" X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="334735884" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2022 01:47:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="769917111" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by fmsmga006.fm.intel.com with ESMTP; 04 Feb 2022 01:47:38 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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; Fri, 4 Feb 2022 01:47:37 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Fri, 4 Feb 2022 01:47:37 -0800 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.47) 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; Fri, 4 Feb 2022 01:47:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjKOHATZaoJVrxk20kdWoSwM1JBdwpjbn5NDk2YdsrYUmxYM0c6aYw3vjfBbY3pbZ/ElDHkcex7UCSnep95Eim7S4K3HBbMDvHFGn1XY5L2IIFuAEeCwMKZ0nY30bGtL38x+pRo3/zZC+bG8z7Z86IaNthAbXSQOHAJRfrjA+bTjA2qd/Q3zsCD9NgKLmIJpHZRefDYyiHDURXH3i9Myq9mP6Hp8HmM7KBDQM+mrZJ/shhjDWOyQ584dfxwSwUju4pzQP9JTlXpTyr1OU2+uvxnTlvYv3RfBHV7GwaggDvaX5qPc+1K6b7qk0y6EirZWEUeNV/1kBSMN+5MSEJN4mA== 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=TFI7oTcZdV0cdDfVnrRNn5DF2wjaB+n035gE+E1wKhY=; b=Tz0ONS7pc26leU7YaQ/xKGqW1lQR3nrVprkuo/Q5EruN/o8fPyJbS2+dQqwrUukrzVvE/mY7rDzHfXu3c5bwMGxmRXBxg4Z1jiPb0ez+DSr1y6HuKd18BvEa3kRM0XQHe5/oxTuhJf5qISeUHCk8kyQbOwIBJ/7bnCQb3nPAuoqE46D0wBnY55dUwiqLRfO/lV87K1GemJhIyOCJZqJwyLTRiLLTog1RL6iyr+VUGZIsXm11F78LtPGkd8q1um3EsBmIWFf7Q7HV81geelYj2a2U6STQJSZR8rn/STsqtAa92vrO3ob+PKg1bBpJo0fCIIWzCGGisn0j8NpKySw8Tg== 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 PH0PR11MB5061.namprd11.prod.outlook.com (2603:10b6:510:3c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Fri, 4 Feb 2022 09:47:35 +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 09:47:35 +0000 From: "Jayatheerthan, Jay" To: Weiguo Li CC: "Kundapura, Ganapati" , "Naga Harish K, S V" , "stephen@networkplumber.org" , "dev@dpdk.org" Subject: RE: [PATCH v6] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Topic: [PATCH v6] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Index: AQHYGaBI8kNGcvfm30GwrUb3hXyP+ayDJNLg Date: Fri, 4 Feb 2022 09:47:35 +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: 2ae3addc-9b36-4df1-29a8-08d9e7c35f76 x-ms-traffictypediagnostic: PH0PR11MB5061:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DrvyDgwfvmWMcHrx6AB9j01ZWtrbmpGWYPxn3KLfDs3nY70joaB+GeYcHX5IkZw9zveo/aXnHoRWM6NQBrDvYCS8QljC3R3amc3Xa0FvQHHNht3EYVZ1+HNs5B7V16bNwFK5uCFYF8PxU5xfhFs0qEEj7/BC/NhFzANk1SoKUzSBAi1vg4B9docuvWDfzr3guXocL586SemtDBNNOVDvtW3K+y1Nys/KXUYriOYDtFFk6ReQK+CIoTlOcxoAnYVrUK14ZeL2/wNSeWpWG7y0+o7UOl6PUeYRCs/N4nhSbHphFJzg79UMupwpQdFQsPWX2oEE/i9da4zVKzZw/czbCRa2LcDlgUBUc/20ptdY3ILe3+AyMIC4LtVMfKWoCJFLhz+iCCaLvUQPNfzs1B10tQecHgmnhWncIF/f+ghrZUhzWFXQ9Zc0n6PyIm4Ip1RkztlBYyBiwjcUBx7r/6rpNNXq0buWghuY6qAN9J29uaHJyz9R1Ko9TqYRmnKi2NzyGEJqbfyCVc/FuZaoo4dpn2l/W0j+NvYrQVmlmqKLY8YaJyWcN67oNYV39XHvAmwHFSXCQLY4ck2Bow21suqCXiqUbM0oMwGkD+7G1x1tQA/7Sxd1ug8M8gH3CQ47ZTYT9Ajgka+GtEstpGjuKN1DovWcjQHKvq48gW8rA1qKJWwxMwMi2aMGhSWOEaphGkv8pD884W1YHAqBbrwMIPSfUA== 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)(38070700005)(53546011)(5660300002)(186003)(2906002)(38100700002)(6916009)(26005)(83380400001)(54906003)(508600001)(4326008)(82960400001)(8676002)(66446008)(66556008)(66946007)(76116006)(71200400001)(122000001)(316002)(86362001)(8936002)(9686003)(7696005)(33656002)(52536014)(6506007)(55016003)(64756008)(66476007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wVxL7oqDz2w2QFcIN2/zIpVP0ivCS06SWJB6AjzQu2hGVS6XOQIEHnkcEQGA?= =?us-ascii?Q?3x6hjq8lJABOPIrdnpqZ9kMNOVn7WmeVfXsa59Qx5IFZ7sFA7+8GLog4YyMp?= =?us-ascii?Q?tyGqgfJrox6OLjqJCjCy5QCfTTL08eboX+N0qoGlX1t3PQTfXscc08Bslqht?= =?us-ascii?Q?g06cWCqI30LTCXPmqp0Wc0A3gSuKaXuvTmX0rVR4pGP/1e36kAIMVqcf9b1J?= =?us-ascii?Q?Gi4EVLXJS3ErFktZKj/MxZERCF9AMM/+0GR5NTroXBxKz58DcnLnRuerDocy?= =?us-ascii?Q?kxXHDJ+g0CRUV7MQk5AcAW9q6H0CpznmQXqW4c8n0UPI+htqJ712EzN+dgkc?= =?us-ascii?Q?e6CvYK4z9ZNm/1Xjj7nvQe7BtqxxbI7Fij8RG4o5jxw5aXmE2vfM9DwWJmAc?= =?us-ascii?Q?uNBt3oOV9UcHdQzEq3xV1OAQamRKZQ2gl3TF7l1H4bFPme9AzBB2WU5uy3kh?= =?us-ascii?Q?T2bkLJsA/DVJs94JLDZvLMcRwVYnivxdb2KAKiywwQcexY8a0c3xtAdthHfT?= =?us-ascii?Q?F43YwzXqncGh2ZzYzYMqjBMNOOIwwFeX4Up9Ng4akTMuuV3PpxDFKKpUpGjT?= =?us-ascii?Q?4ye6XzbcUK09+riYPJjldT7jfbUlzPBwlNfi47IYBw2Geq3hIp4gtMviRZc4?= =?us-ascii?Q?+1c7KarN4lGHAZnIW5ITubsToM+edv2SZ+3Aq9Y9fzPuyj10s249viS9SGDU?= =?us-ascii?Q?AT93PzOpbUEm8Nkk59kBI+seVQbF3/MsxbWZr/cTB3X4LgctDigJSggQM3hr?= =?us-ascii?Q?klZPHCPlFBO7uNqnI9Yro2Sn2TsoDUclwb4sEq6kzlLZKz9wSYa2jziI9z7f?= =?us-ascii?Q?oX3JHhqjuxEkd+/4DYxxftslsygI/dYUHsPRLgFeNzjLzhCA/y8hfhEAVAUZ?= =?us-ascii?Q?AMysoCMkCvAB9f2Tgy50UOK7jI8POt11q7Gt4mJjeODpIzfhtYgvVEsq2PNd?= =?us-ascii?Q?uJt8UjkOp4cWbEyRd+QAnYDoa1URmQgoFai9/srEDPBQr1glec137qvDPY9Y?= =?us-ascii?Q?gTt16N3800NgnD4mgGhwutyoPWBBqAi7J5AjrtC+rQ6RWfxQxykX+7HjzejE?= =?us-ascii?Q?t4A+ducu+67cSc3vKTCrHjVmUG2rmOfi/Y8xT9+xoxTQH+7OLUSs/5MximIy?= =?us-ascii?Q?VsI9hPyMJrike27kNUaOpdsm+12hsIK28qwpJ1mQyPM/2o7THzVEATb+XVTg?= =?us-ascii?Q?3dcRBsJflpbaDw6HlX38oyXhSsaauuNMuTrBkmIeqG0BJ9lsNL/J+ET3eZWk?= =?us-ascii?Q?PF5lcQzs2v+XSVTG8kV4u1keNSZuzPAnM6pXMHHCNSJAJ3sb1f8R31rb7Et/?= =?us-ascii?Q?b22K0/D69k8hqfP/7RSp50j5VOF/2ND84opxL5dEvan9jlj+4AGK8ePI0n+O?= =?us-ascii?Q?fwWHIOtjscPio+iuY4y7CbBicuKvdkMx3HcMIvQ9p2HEuPlKbm256XT4Z29f?= =?us-ascii?Q?r37LL57m9YERcsn7q3DUPNOq07HVoIf6mHWzRQuRrXrLth4aaIzf7Sk0JGV6?= =?us-ascii?Q?2q5q/houM4UqQxFXC5fMwNgIGbRFQzKEeCpDse3VTVy+sxE1NKD37n0yY/hv?= =?us-ascii?Q?/7QyE8GsxCRSI95xlVxHNmazbzvaaBQsBn1/YPNZSbYuhK5e8jXlUCz3NlnE?= =?us-ascii?Q?O0xFHLEw2IMShVV9NVAS1dgW4wSzJTJjOHEC0MThDCfksAookepSpGPM814p?= =?us-ascii?Q?CtzEMg=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: 2ae3addc-9b36-4df1-29a8-08d9e7c35f76 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2022 09:47:35.4604 (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: lNJy81c3/9JphH0OFqP/hWHAD6k8iFGQEmFAZHgPKEpDZA6pIAm3J880UwxjdLcxtXIXphMRWMXG4CuL6AadyxwIpdo5H12U3FYgQbsCaNA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5061 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 Looks good. Thanks Weiguo for posting this patch and addressing all the com= ments! Acked-by: Jay Jayatheerthan < jay.jayatheerthan@intel.com> -Jay > -----Original Message----- > From: Weiguo Li > Sent: Friday, February 4, 2022 1:51 PM > To: Jayatheerthan, Jay > Cc: Kundapura, Ganapati ; Naga Harish K, S = V ; > stephen@networkplumber.org; dev@dpdk.org > Subject: [PATCH v6] 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 > Acked-by: Ganapati Kundapura >=20 > --- > v6: > * fix double free problem in v5 as Jay noted > v5: > * fix according to Jay's comment. > * fix anothor bypassing the freeing of memory problem > 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 | 96 ++++++++++++++++++------- > 1 file changed, 72 insertions(+), 24 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..4da6f1ff90 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,33 +3356,37 @@ 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); > - return -EINVAL; > + ret =3D -EINVAL; > + goto error; > } >=20 > token =3D strtok(NULL, "\0"); > 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,33 +3428,37 @@ 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); > - return -EINVAL; > + ret =3D -EINVAL; > + goto error; > } >=20 > token =3D strtok(NULL, "\0"); > 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,33 +3498,37 @@ 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); > - return -EINVAL; > + ret =3D -EINVAL; > + goto error; > } >=20 > token =3D strtok(NULL, "\0"); > 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