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 57C44A00C3; Thu, 3 Feb 2022 14:09:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D406440143; Thu, 3 Feb 2022 14:09:08 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 2668E40140 for ; Thu, 3 Feb 2022 14:09:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643893747; x=1675429747; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=BcvFhipX6H7Vy+4M+HsqxoqwyF6TkG6CDFT+BOWi4v4=; b=Iq6a/sGf/AuOs91o8YmA0pjU40p225Po/0SH/9OgTt4/0BY8pahTgtGi PgGq78qOl9SAxLrW7C4LE7vJsLSXX5ZE6BPu455UtrFJxBEEf6ljHftHE M25a3ArQ2AKwHtnpsFkDZkIOzQajwljyL7LG4tU9UIugP2Vqgk37QeADt Q8sB1XA/2QwO10aFnEo2i67vnKzddHO2bM6GUymrMUfoFR5qkXTaOMinR pjPNMMjOfKwQWkfzqPQkbnt75EJuRaMAMyHxwH1G8D+ERjhbyKRbHoTW8 ZfKhqpCjj7h4U7QBToR5gKY+knl8w3+LNeaN2TSPTyWh+QG08eFwpLmZb Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10246"; a="247905004" X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="247905004" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Feb 2022 05:09:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,340,1635231600"; d="scan'208";a="699307679" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by orsmga005.jf.intel.com with ESMTP; 03 Feb 2022 05:09:05 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) 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; Thu, 3 Feb 2022 05:09:05 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX607.amr.corp.intel.com (10.22.229.20) 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 05:09:04 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx607.amr.corp.intel.com (10.22.229.20) 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 05:09:04 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.48) by edgegateway.intel.com (134.134.137.100) 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 05:09:02 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYPXp+Ecj5uenEYtAIcZsBSfRM8FZ+EPKoGXk2hglWxEqyyl51326NTVYyvIzNJ8lTKjEFAFMSjyrHcjU0u5J5eN3kp0ICKyxpjNUWHPcmJarCi5ABOu0DyUPsgF70VmKcvKlLTvr4pNhcT9fYtUhw7cvDrIYTAkJTty/OsvuZNKLF0LTKtQCN3sWqOcj+EwywU+ue/0PltY2FfZaAyWLJuZap47qML23zVcoKqwmh8U/Glz2PkrFBqqKGzlFj8vGG61eMzllDlv/3zOfaKOMT2moXHvw5BPAq/ijP6wYVtJOmzkqBY5jNgxWF+uswj7qppJ8Be9XqJBD2i5YHmZAA== 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=FPMV441TzPDMjCNlw7sBRMPoG+LwctdXyRaVaNnHlYI=; b=R4bupTyKSWvms54qOsqnfI0zsOHJH3aKL0+8uNQRtce9hKRFNPcfrtdYSNIqfg6s7Ti3VGrkdINKReaZJCixQkBcE85MsEi5KTipmufgZAjJeG81Dpu5XHvu/JOXicLgnM8y9qWFNKLnbw/a1erHjpO/CHaQbmzjJ5CUwkfkuSKxR0UT4dV1FYtz3INwr1AL4TiImYScOrfp4SO+W8PVb1CTaVpLng4MDG1zZusa8j0h/BYSw16uzmjBE16OeLhJtILpRdA6hgFNh73d7cqMir+3WV5QUl61SJOEIqufcqJ6rjDysBUkmeRrUKR89IcXfkOZtUWDPAIWjNdjaKGprg== 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 MWHPR1101MB2126.namprd11.prod.outlook.com (2603:10b6:301:50::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Thu, 3 Feb 2022 13:09:01 +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; Thu, 3 Feb 2022 13:09:01 +0000 From: "Kundapura, Ganapati" To: Weiguo Li , "Jayatheerthan, Jay" CC: "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: AQHYGNscVKnDL+t3l0GkBnb6NmkXNayBy/Zw Date: Thu, 3 Feb 2022 13:09:00 +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: a4d2c871-4408-4fd4-5bf9-08d9e7165888 x-ms-traffictypediagnostic: MWHPR1101MB2126:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2657; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 1yWVXAPT/bXm7IP505B8zf2xvdJ0xc0ZqPXNVaFnIwiS12TOALrxa9mPBBfWBpkHXqnPmdcg/UWPcvTtwnFp2dYQ0H4MHeSjzn3XXhbROFV5arT35s4udfXXyYGXr8Ko5zpsf3Lu9lgOx2YeCuagw2muon/oR3sYlprawGLXLqma+4sBQK4bOBLX5bp8N6cZDytNEOPggK+T+a6KPATP9USO40t8A84bikhNuE5sqGFxlj9Lkq4uNSaQWqHwkn3b/Dsf3ToUpfP0TrYzOCPndLM30+HsRhAfNE6tSSY+rI1ansnnv2WTponv4ou/CTVgbAAlbSykvhQQkGHIFMQMElYIi2kJ5fKe25UOjwfcrDAcFmh25HRd9Yxf+VgsrHjY5bqKvpmuXuooxaNRUmWdUT6k1xAO8j3dtYWmI6FIQvFqGxUSLz5mKsyF2Q24Nfl1h2ORaImgJ6B9UqPGQEiIa8P9a0w3m6m8LrSYRu1TePhZ7COUKRWIE3uDEoipcYmn6+J/rFKEL3Nc+1Mt3VsS0A+Q2WhUw8sjHZHmx3x0+LV4P9udCRSKULsKLP2N1fd/gWtuLURm81INe4CaTgLxrPtyF7LTyZtSciyTXwgHViUAj7FLFn5uUH5hNGqKt/kF4CDGSsRPa362lfr+pC1IlyU4bJq2px/nlFfL3gwytoaTyDaQZaoL8JtlcZP5VN16ecDPpmiVxfsh+hMSA/yqFw== 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)(9686003)(55236004)(66556008)(5660300002)(508600001)(122000001)(52536014)(7696005)(83380400001)(86362001)(53546011)(66946007)(6506007)(71200400001)(55016003)(8676002)(66446008)(8936002)(76116006)(4326008)(66476007)(64756008)(54906003)(316002)(38100700002)(6636002)(33656002)(110136005)(26005)(186003)(38070700005)(82960400001)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?GOp8YdO1CjoLJRkFdX2yjIjPJAZ1JtxsYO+5gxCXyUXYXgnfxiwJeCp7LKpu?= =?us-ascii?Q?gcAf5usWxlyb2eEYfrmxc1EPxvh7i855PD5VyN5CJTrrZlabfkdYonydB/3o?= =?us-ascii?Q?AFWQNjOPva1Hpomh+ZTP6y9/SDD+DlD6PfSSmUjI/HohM59nmLVshlQT32Aw?= =?us-ascii?Q?8AorfpWMXp2hzl7x38BH49iVWR/zspPZ5kAECH/nzKSt83Y39eNkRmaVvQ9P?= =?us-ascii?Q?gOWyebOb2Mi0FKPKp9OzSfRVN03MJeiPU0eN9+RaCL8ftdhRJ2r74t7shw/3?= =?us-ascii?Q?wmax6FGP7w00dbuGh42acY0Ssw15q6G400kBmtZTuhZ9JWUmimUMByW02bg1?= =?us-ascii?Q?hgHT1OQKzJlViv5PSsMO7tniYTdBOPqV/thcIjYztUyt/59G9QQkvt8XchGQ?= =?us-ascii?Q?jvgJ1zUl4+6KNzFlxYEiCb1nHAqm1z4QLN+i7Uw7OW4EPUoG1IFK2dz4NE4w?= =?us-ascii?Q?UXy0kvcHA66GyGPSXH9uRkvP97O3hwpfkkzaUuu5BXAwscFQZnSGyxR9UZ8E?= =?us-ascii?Q?bM/WLF+d0/Zbf1mL7VD8oHqxlxXTlxaSWBjxJuNGytweDcLoV52lT7yTrajm?= =?us-ascii?Q?Pxk3Qj2kt1sFLuRwS/zML6RXqOv2pgMBFo6cFqHzqksvq8otdLDWZpyIcBcP?= =?us-ascii?Q?bKSWn5Y/IOV+Vcnv9FTnhA4RE8hFuDyOawXC09ILMUV8mpdglEkYCWJ/MIKO?= =?us-ascii?Q?iyHxfsDfPRAqD3rt8NQUJ67/LyFJ4HvmWOpF0PVrIlYjvMVNgQjF0t2BGIAw?= =?us-ascii?Q?ZoLLYoej/WDOe6LOfHzyefkYKkGQXnEaiwaAvV+4QKRfp4BZmaejJ++IVOJ0?= =?us-ascii?Q?pGFcnyecNg++qw0HdZYP4SDmTpOb6EtCtWwHuQZQ59PWQhwKT3IwMkcYjIKf?= =?us-ascii?Q?OTu3pPqIzDfejdz1vkitNU6+wPGVnctE7L6BtiGvPh0Hk2CNUJEDlUowQ5jp?= =?us-ascii?Q?ff/8v4VTszuZTlVW4N84U+u0QjDK/DHiZBTSpnO+f/VRBFQqutlwNf0NSaD9?= =?us-ascii?Q?20XTU5No02B5jwKQTowRY5VRZDtACohn7wNkdPJog8e8FeqzY90AF2wRlyW4?= =?us-ascii?Q?pyTzQj9ib7hmhzb4wy8dkPmwb1kX/Wh+4uXT2Imq0rmg3ow312n/navjqWqe?= =?us-ascii?Q?6nkUeJd6y5JGruZlGXQ39w9tLwDxfEePNa/LEnxi00tEwnO21wFs792HZx4C?= =?us-ascii?Q?dFK76bNU5lX0drf+oLtrj0ShlBDvWVM0M9YCVbgRK2VdIDtejZnXvEUr/WhP?= =?us-ascii?Q?pTSMRzHAM7fbBshxMpOGAbqD2nbG7pn/WWdjpiy2SdqBnyCM/ME1+dGl8yAp?= =?us-ascii?Q?nHysPSd4i8Bq3rSSHa29EadZUaI0witgdleV93FzFL/Ww1BD/MI5yZDCyw2J?= =?us-ascii?Q?wCrVdmQX5pVbg1Hk8yMfTUgEU9XYNCZK22sUgLnhZd2RQHftwOFBpNQmh6eq?= =?us-ascii?Q?sFAkD8UcfgTk6ARfOtv5BScCTaILOntlRzj2j5hctFuB7L+Q1SCxwBA7Z12d?= =?us-ascii?Q?D2RTd7TlHCtE8HIhVZpe/N9gEuNhDCyc6CIcLGzfF/xlEyv9lHg6p4DRnaoY?= =?us-ascii?Q?zcVMZb89G/jY0ERyq/0cuF0gMytkNEXqm97ILMGpuEfrHYmKMbSnL2P6LX8v?= =?us-ascii?Q?4qQH3av2C8AWQPClzMtlY+4QVo4kA2Cs6qS49uW7ReoGo9W1lwQNXKEt/mQc?= =?us-ascii?Q?LBReog=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: a4d2c871-4408-4fd4-5bf9-08d9e7165888 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2022 13:09:00.8545 (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: V/dpldQhbAsPXK8wHg52QlwKU1DLyvRJaP4iodbKraoP1Sr8EuDnLZFcNYCmdL8DDGSBtZzczmnzStpjJTH+h+2jBU9+eUC01zOvC8y+qiI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2126 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 to me. Thank you for catching this. Acked-by: Ganapati Kundapura > -----Original Message----- > From: Weiguo Li > Sent: 03 February 2022 14:20 > 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 > 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 >=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_event_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_adapter, 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, > retval) 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_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; > struct rte_event_eth_rx_adapter_queue_conf queue_conf; >=20 > @@ -3332,26 +3356,28 @@ 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, ","); > + > 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_a > dapter_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 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); > return -EINVAL; > } >=20 > @@ -3359,6 +3385,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)) { > @@ -3378,6 +3406,10 @@ handle_rxa_get_queue_conf(const char *cmd > __rte_unused, > 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_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; > 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_a > dapter_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 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); > return -EINVAL; > } >=20 > @@ -3423,6 +3457,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)) { > @@ -3441,6 +3477,10 @@ handle_rxa_get_queue_stats(const char *cmd > __rte_unused, > 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 > __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_a > dapter_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 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); > 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