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 2CB6FA00C3; Fri, 4 Feb 2022 08:57:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA6E740143; Fri, 4 Feb 2022 08:57:56 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id CC81F40140 for ; Fri, 4 Feb 2022 08:57:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643961476; x=1675497476; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=t2Qzweqj25RX5GKT8iyTCcbqbIF5mcyAKqddXtTxwyA=; b=Kj0k45WzK8WRMliDA5lWj/r8yc0QnZwgB8k/vB1pEy02Ce/MdFHbopPy cHXg6xsq1rnE5uj8gPQRVIqbIMEfr1LpwkFLD6XJmmuZEXery/+8h9dCp wZI3NC+fBHmnc8lXu9kpo3FllwgoWSs1v62PD3+qiBEKp4NSzqACUnYfx ffFLIqNFg9Mki94A99AZV+S888/iLV0zF+7pnR/9dSq4cLv8W2K2pzhVj pXbx/AGjz6mFDMe++cxsfcwkgh2e5BnnNcrxvOWlND2mdVnmHQdTRxVy1 I2yeR336of2jcMyRxJDEtmDTiCj7D/pEatWExprSYm2rC6nI8VoxqXEkc w==; X-IronPort-AV: E=McAfee;i="6200,9189,10247"; a="311630622" X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="311630622" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 23:57:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,342,1635231600"; d="scan'208";a="566677700" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga001.jf.intel.com with ESMTP; 03 Feb 2022 23:57:54 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) 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 23:57:54 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) 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 23:57:54 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) 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.2308.20; Thu, 3 Feb 2022 23:57:54 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFYqlBLpRc1RzsdECOYaNkkgwadYfbA0cRPT6Jlz+82MkcTCi+lIgLjvvBmlKD4/1eU7+BXOFIZRG/7ZXGw7DUCz+/MfAep7pziVaeLrqRnY4QjhnLKxOssYgO+/MkO5V2a/1oowFgq1hbpMbHENxbQq+cly79vNNvo9FCxsGRA8KLDBgfls8D8Kd83mCWeMMNL49R4bWoe1kNBHkNuV61gSLCIdQUs5M++/LqUY5n1GlRNg+CbJNLoSvkuEDnFowIWqCk4indDZTzGa+9gDWMUzxdF/ftuLW7niTQxdb87CFqSzWNX4ZFtNCCD0ny3TN82lT88lEiHojNbdW9sJIA== 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=sqsbfupHdmXVg0Qgm5WOgpm5GaUIgcjsJHvwMCsQgBw=; b=SMnoJmOUn+EBnLK8I/hfvpeUeirMc/AIBfi33hesSmsNlcg3rVQBd6hqBlwmgvLSoiTB8lqIg0weSan0yp4Jq5UKaYXXxpG1+TzgedLqLZGywuhP/l/dXxCnDY/nzxWt0xJB8+6sl1matVVFkLjdaGPhTgINYqxIrF9sja2Zz3fy4bHZFRJ0O6AnDS7CrpytfdThQ0Gg8tYzgNUga70Y/zyEgEapV36Rwg3IS4z8EZZEuAgoSKpNNJazAQDrbHo2fewe5cgQcCO5Hhx+JIW07ZPt+SO9SWrthO+M8SAf1YKj/Sd4a272CS8eyWvcscvrPnancpHjXqE+2HMRkfsBgA== 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 BN6PR11MB2017.namprd11.prod.outlook.com (2603:10b6:404:46::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14; Fri, 4 Feb 2022 07:57:52 +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 07:57:52 +0000 From: "Jayatheerthan, Jay" To: Weiguo Li CC: "Kundapura, Ganapati" , "Naga Harish K, S V" , "stephen@networkplumber.org" , "dev@dpdk.org" Subject: RE: [PATCH v5] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Topic: [PATCH v5] eventdev/eth_rx: fix memory leak when token parsing finished Thread-Index: AQHYGZvyzr0oiv3inkKRyug+tWcn+KyDBeWg Date: Fri, 4 Feb 2022 07:57:52 +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: 2fd9d741-3c1c-41ad-ba71-08d9e7b40bd1 x-ms-traffictypediagnostic: BN6PR11MB2017:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:843; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xjNxIe7SKkvlxEGvfg9fKIYa/Bv5C23yRAmQWHH6DY3mFNcyQH4BBBEWxsRudcf+ps+njW/vnTWT3JU4lVYwcoJwbBsroCgKPz8TnapVttOV6+WhVfyvQwJWWNNBVH9sYPV9KnGLDCinb4TLjU7s9v0zYVmXZjkPTBYm8VDHKplu7yI9/fvcTFkgRivIQjYv9VaLbPnCuadkcFq0uON8VQj2TtXiRBDsg9qCCVgrKSM39b8N4EpeiXBjVb3EfwRW4hf7+H4jmInHQorEuARNG9IRX684LfOa8aGpgrVItV5vLPrG3fnC+UftvFkA4ovf2FU2P4mYLyNvAINvFRmQaohaBlVirMFAg1yaaAqBJYrWp5XQtWRAB0hMG3NO7iKZ/gBco7WrZ4J2zf4T8AbQO8+a1LRwfrkOmiVZR6oPRcrvvrQqaH+WlH+ShapEVLGzy23J1xUiLxXBEfEo6CZvrgYZXA/XYKnQWHI/vPexJ1wlOEn40ebocoN3lcGokChOWaDsV8AtxudUlPsmhJjnYAY4UEPRFjMATto+FpXRGIN9TBR0fZm/5wqTClkO6F/Ron0+bjvbbQorIrACSbSEZNtbUyd4U4SYoeLvk2DLDrkltBY/ZFFSaQk2uzNv7KOPCzElf87jOXb9fJ026j8MKVz3A3Fo/RuJSDgX2f52EtDQmvOJEyiMusKxxQAre0evzk6CPkuKiAo4pPObNHIxZg== 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)(33656002)(86362001)(38100700002)(122000001)(38070700005)(82960400001)(55016003)(7696005)(6506007)(4326008)(8676002)(8936002)(66446008)(6916009)(71200400001)(66946007)(53546011)(508600001)(52536014)(9686003)(64756008)(66476007)(5660300002)(66556008)(83380400001)(26005)(186003)(316002)(2906002)(76116006)(54906003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ONuA67E8W0gt0v08qo8HmZ2YenEyKDnF0t5dgAdtBJuRHUvaAz+8S3AAPjkI?= =?us-ascii?Q?yB5qlcY/Axas1Ve6DzuMbC3TVZolZLvFo536KAB8UxO6qmGN2fIHXo0xLT/V?= =?us-ascii?Q?slGGjpdK80F6STgT9ebrsOXPu+NwE0wsOozvNLINSKA4DG1oBB7RYD6wNEf6?= =?us-ascii?Q?0zfmVFKrEL/Qb9UHeeTkI7myaOLbiOwD1B07xcwLiLlIfoRj0qy774Z/IYK5?= =?us-ascii?Q?hWRS6L981BAGhzRXgDBGtgz6RRMs4fn2EBEo7GKiR0TBqgr/wcg+nZbVknbi?= =?us-ascii?Q?sQWX1lEql48vBzCm5u9WBKX7xsIXAXT9ErvmbD4nwTosh8CUEFujdm77Ua9T?= =?us-ascii?Q?xLBcuT7MQ4TK6elAPDWaMP9fyiKfOR7B1gxoFMrCIIN+7Rw912b5PujJ4KaU?= =?us-ascii?Q?0ZBVu6b29rahhxLsP67cOcs+Wbn53QZnpP0JGfK63ocB2UG23crFks4D7LEc?= =?us-ascii?Q?7OvoSKG72M3K30NClMMxaj3qZ9qpUC873X2zzzcvI6Wc60u/sVLtSpKSeoNV?= =?us-ascii?Q?gGLvAzSEg+9Y62dKNRPgr6SKk1LpCJtDmBLDSzQKau2TYNJxSKwfjC4Qqa2C?= =?us-ascii?Q?OO2AJia5F08zTL532D1xQpUaekDs8TSQ/cjj201V6G85N27uVf3LfoeQSR8P?= =?us-ascii?Q?jp9ryQnDry96kYqYcARd2zK9BK136pVO0JdJJwqfIsum0C6zsDfIwyK2lhaU?= =?us-ascii?Q?NWwIVp9Ibt9ILf8S7+uH76UcokY6wzvDwlBz5tGVYq+xpY+Ap3CUdolxhqPV?= =?us-ascii?Q?nJ3PbxQxd2WgF3dSFWQegR6kApmCApsu1JtkQ/9Rml/TU2z/k0mX6AlygXf7?= =?us-ascii?Q?Qw0EcrkLIJB0PZiFZ9bM/DN9/dh+sjjpj40Szw7y4QN44VubRdRIqUr+iRU/?= =?us-ascii?Q?/W34D6kmgESChaE34GET3ZwhMMXgJSmmUmhL3VxxBJ1iiI6zFW7ozEorN2rR?= =?us-ascii?Q?cDoGfjhPY4P56v3W6BuM7X2u7KPQ0qAGMKQ5WFKFrtw8sbr9hro3Gm43YbDE?= =?us-ascii?Q?E4x7ZtJ1UWPNfqwTNFCEqsez8F71fhK6069MOidLCHf19a42etspU4DnJqAH?= =?us-ascii?Q?b/lB2dUU+dvbw5E9MByRv9RfDAzluSglSFixH12vsVJrGZj6nDAQYNrT6Y6Q?= =?us-ascii?Q?tKnP3Ns24B73ZuF+wm5L9kbIlW3tbLbI+enpp77FlTfoPsAMHY2MyRubmYqc?= =?us-ascii?Q?WXCzIuHtCkkzQ6pyXTtsR4Cd+Hv5ajSSxdVTsflK8zRvuYTitU5o7mahgRlr?= =?us-ascii?Q?mTsFfhP88Kc8amrEDyxl4cVrVa3Z1A8RHqCzKF5Hqlx32BkTxEOOpzcSLgKt?= =?us-ascii?Q?OMCt9IXcND0ue1ytq5KODF8EDQCWmQZ8Ah4tm7bvVnibcCgpGzewV1j/+3l3?= =?us-ascii?Q?ytgunvuIDXnXF+wwRC1gGCwZ2cxURs9m13dMVL6HKgVlGD1HTl4zaYmzUDQV?= =?us-ascii?Q?bRUOTPzxG2ZHl4NNi8dP151uyKCJ6joHeeVU0ViVuqQ3FfSNMn5WmQUqi+iv?= =?us-ascii?Q?XLPk2l6hEdkkhyUMYsgWuVk26lM9YMgfPm6iYWJ7XQywWgugwTmXsFSZ4FS3?= =?us-ascii?Q?NU8t8EOe2oz3OBeKE7PMFWhtarVLam+0Bn7fFA8GKN7YKqrCzAeC5xsuMoO6?= =?us-ascii?Q?hBO4rTLhW9+kdp4WdQO3SR7IeyTReh2BiPGYWfyM3LeA8W6qprcIqrP9gmBv?= =?us-ascii?Q?TaGy8Q=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: 2fd9d741-3c1c-41ad-ba71-08d9e7b40bd1 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Feb 2022 07:57:52.7434 (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: lb7RRQbhqptf/xlwyoQxsZ/tePaNHkulhvYY3QoKqZlE1V0Gxho+qWA+Mj32Adwj1oLvKaazHDtE9UksAhKeBA/kfDZwDLcsd4c86JHA4p4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB2017 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: Friday, February 4, 2022 1:20 PM > To: Jayatheerthan, Jay > Cc: Kundapura, Ganapati ; Naga Harish K, S = V ; > stephen@networkplumber.org; dev@dpdk.org > Subject: [PATCH v5] 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 > --- > 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 | 105 ++++++++++++++++++------ > 1 file changed, 78 insertions(+), 27 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..719ef520cd 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,38 +3356,43 @@ 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)) { > RTE_EDEV_LOG_ERR("Failed to get Rx adapter queue config"); > - return -1; > + ret =3D -1; > + goto error; This causes double free of l_params. It is already freed above and then one= more time in error section. If you want you can more above free just before return 0; > } >=20 > rte_tel_data_start_dict(d); > @@ -3378,6 +3407,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 +3420,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,38 +3429,43 @@ 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)) { > RTE_EDEV_LOG_ERR("Failed to get Rx adapter queue stats"); > - return -1; > + ret =3D -1; > + goto error; same here. > } >=20 > rte_tel_data_start_dict(d); > @@ -3441,6 +3479,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 +3492,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,42 +3500,51 @@ 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, > rx_queue_id)) { > RTE_EDEV_LOG_ERR("Failed to reset Rx adapter queue stats"); > - return -1; > + ret =3D -1; > + goto error; same here. > } >=20 > return 0; > + > +error: > + free(l_params); > + return ret; > } >=20 > RTE_INIT(rxa_init_telemetry) > -- > 2.25.1