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 93D63A00C5; Wed, 2 Feb 2022 07:15:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D2FF40E03; Wed, 2 Feb 2022 07:15:56 +0100 (CET) Received: from out203-205-221-242.mail.qq.com (out203-205-221-242.mail.qq.com [203.205.221.242]) by mails.dpdk.org (Postfix) with ESMTP id 2A9E940DF4 for ; Wed, 2 Feb 2022 07:15:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1643782548; bh=5r4Qhp0bmQkOz6uW+hkdGAxCGnZ6CBlHharbRHC9JUs=; h=From:To:Cc:Subject:Date; b=sL8If8U/+SZkFbgXp2t2kb6tZLL/gfgx1Y1PGGK/oEzZ3+B6H6R1eft9ggIDN4tPn hhhVw8tutAL3dKo0/JaC/4L7IcwLxcyOD8Q3u5hbHiqGglVJkvVVT40lRZ09T+NF0g 7sVN0KNbVQzf1wmItRO+BKxJISGuV1LBNdN0JSIs= Received: from liwg-ubuntu.lan ([111.193.130.237]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id 3E983A05; Wed, 02 Feb 2022 14:15:41 +0800 X-QQ-mid: xmsmtpt1643782541t8rwspki6 Message-ID: X-QQ-XMAILINFO: NGeU787RzUEM3ntB7OuiTl2xuJwLSdYTeQmbMrS75KEKAuTWue+3EwV2WjCTr8 kclmBecGDeuwQHSP9I0VSaiUa0FQLWc6cBx5uprL1nWiIBF2+h/1KODRryznEgs5ygjORvSWm6Hh aGHZa+90zdLaSFJOSxmKerHofpnm17vMi9Ip7n+Vcfa+I0QsmBbdqlbHvlb+rGiaA7T41oAA6Nh2 PskF6JFbfEk6Rto4yQu3w3XXlMRQWloA9onTQYXCDJJ+V/jnpES0uviNS2rbOHGTiNLuQbGNDvYY XXNPIrFfYztFeoPm3x/jMJoicoGdMenbGzGKkeBjHsnAQ213OOcCW31bNYQK3riDEt6E+rsOfZ8c 9UHWWh+CzRmt7dYdDbKVE36P8y96fyP80jaFYE8z91hiJE/aBQsi+gMgt1Gu7btALGTAq6WEdqVx WLUjH/QYWMKGgGLXKdzB5YzkVDGU9CyGjTTLD2tRiY370f3b2dqDgVSPPeIPIxc9px2/gvUZwqfh mrz537MJJkPVQeSbSY91wfLgy4aKBAVRkmhdGWqS4HzMIS3TXHCJTcBgLq1yJiPM58AAjT2639B8 6rQsOkx1Ck6YpdeUMAdP/PvcUnAi6ojMYn2QTS5IQCnvTZ/NPzsXVlR0mF2tK8kzSqP+nHKivQQc QESyj24FfvWdQ+lsX76DEYw8Ftr3h+orBUjfwCvP04589Sg/+Jz3G+W2EXo2a0FSCkZ6KaJj0DMD rUnkpbWEmq/nm/euqMgjO5ciL+mlWOZhJcd4VqBJqmIICATbOqyf3FTahUA62J1hCTxEDN0rVfmQ SiDvVTmq3+Cg9W3fepaNr8Lo1Y4zumu2qE3Zh/z9+SxIQ2lGw7N0ifVg4K2m5Gxj7JWgajfDWUo4 Mz1n4CyxsWwxaYCioRJZQzGd6ZAXwrdA== From: Weiguo Li To: jay.jayatheerthan@intel.com Cc: ganapati.kundapura@intel.com, s.v.naga.harish.k@intel.com, dev@dpdk.org Subject: [PATCH] eventdev/eth_rx: fix memory leak when token parsing finished Date: Wed, 2 Feb 2022 14:15:41 +0800 X-OQ-MSGID: <20220202061541.1597183-1-liwg06@foxmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The memory get from strdup should be freed when parameter parsing finished, and also should be freed when error occurs. Fixes: 814d01709328 ("eventdev/eth_rx: support telemetry") Fixes: 9e583185318f ("eventdev/eth_rx: support telemetry") Signed-off-by: Weiguo Li --- lib/eventdev/rte_event_eth_rx_adapter.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c index ae1e260c08..4173a52981 100644 --- a/lib/eventdev/rte_event_eth_rx_adapter.c +++ b/lib/eventdev/rte_event_eth_rx_adapter.c @@ -3338,6 +3338,7 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get device ID from parameter string */ @@ -3346,12 +3347,14 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get Rx queue ID from parameter string */ rx_queue_id = strtoul(token, NULL, 10); if (rx_queue_id >= 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; } @@ -3359,6 +3362,8 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused, if (token != NULL) RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" " telemetry command, ignoring"); + /* Parsing parameter finished */ + free(l_params); if (rte_event_eth_rx_adapter_queue_conf_get(rx_adapter_id, eth_dev_id, rx_queue_id, &queue_conf)) { @@ -3402,6 +3407,7 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get device ID from parameter string */ @@ -3410,12 +3416,14 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get Rx queue ID from parameter string */ rx_queue_id = strtoul(token, NULL, 10); if (rx_queue_id >= 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; } @@ -3423,6 +3431,8 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused, if (token != NULL) RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" " telemetry command, ignoring"); + /* Parsing parameter finished */ + free(l_params); if (rte_event_eth_rx_adapter_queue_stats_get(rx_adapter_id, eth_dev_id, rx_queue_id, &q_stats)) { @@ -3464,6 +3474,7 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get device ID from parameter string */ @@ -3472,12 +3483,14 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused, token = strtok(NULL, ","); if (token == NULL || strlen(token) == 0 || !isdigit(*token)) + free(l_params); return -1; /* Get Rx queue ID from parameter string */ rx_queue_id = strtoul(token, NULL, 10); if (rx_queue_id >= 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; } @@ -3485,6 +3498,8 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused, if (token != NULL) RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev" " telemetry command, ignoring"); + /* Parsing parameter finished */ + free(l_params); if (rte_event_eth_rx_adapter_queue_stats_reset(rx_adapter_id, eth_dev_id, -- 2.25.1