patch 'eventdev/eth_rx: fix parameters parsing memory leak' has been queued to stable release 21.11.1
Kevin Traynor
ktraynor at redhat.com
Tue Mar 1 11:41:35 CET 2022
Hi,
FYI, your patch has been queued to stable release 21.11.1
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/06/22. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/529f3a735e4eb837049e340c1334ea6a6355397b
Thanks.
Kevin
---
>From 529f3a735e4eb837049e340c1334ea6a6355397b Mon Sep 17 00:00:00 2001
From: Weiguo Li <liwg06 at foxmail.com>
Date: Fri, 4 Feb 2022 16:21:28 +0800
Subject: [PATCH] eventdev/eth_rx: fix parameters parsing memory leak
[ upstream commit 74b034ff817239b1a5dcf4dfd7d33ccd5684996a ]
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 <liwg06 at foxmail.com>
Acked-by: Ganapati Kundapura <ganapati.kundapura at intel.com>
Acked-by: Jay Jayatheerthan <jay.jayatheerthan at intel.com>
---
lib/eventdev/rte_event_eth_rx_adapter.c | 96 ++++++++++++++++++-------
1 file changed, 72 insertions(+), 24 deletions(-)
diff --git a/lib/eventdev/rte_event_eth_rx_adapter.c b/lib/eventdev/rte_event_eth_rx_adapter.c
index f946137b25..ce94999738 100644
--- a/lib/eventdev/rte_event_eth_rx_adapter.c
+++ b/lib/eventdev/rte_event_eth_rx_adapter.c
@@ -294,4 +294,28 @@ rxa_event_buf_get(struct event_eth_rx_adapter *rx_adapter, uint16_t eth_dev_id,
} while (0)
+#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 = %d\n", id); \
+ ret = retval; \
+ goto error; \
+ } \
+} while (0)
+
+#define RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, retval) do { \
+ if ((token) == NULL || strlen(token) == 0 || !isdigit(*token)) { \
+ RTE_EDEV_LOG_ERR("Invalid eth Rx adapter token\n"); \
+ ret = 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=%u\n", port_id); \
+ ret = retval; \
+ goto error; \
+ } \
+} while (0)
+
static inline int
rxa_sw_adapter_queue_count(struct event_eth_rx_adapter *rx_adapter)
@@ -3304,5 +3328,5 @@ 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 = -1;
char *token, *l_params;
struct rte_event_eth_rx_adapter_queue_conf queue_conf;
@@ -3313,19 +3337,20 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
/* Get Rx adapter ID from parameter string */
l_params = strdup(params);
+ if (l_params == NULL)
+ return -ENOMEM;
token = strtok(l_params, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
rx_adapter_id = 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, -EINVAL);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get device ID from parameter string */
eth_dev_id = 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);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get Rx queue ID from parameter string */
@@ -3333,5 +3358,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
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);
- return -EINVAL;
+ ret = -EINVAL;
+ goto error;
}
@@ -3340,4 +3366,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
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,
@@ -3359,4 +3387,8 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
return 0;
+
+error:
+ free(l_params);
+ return ret;
}
@@ -3368,5 +3400,5 @@ 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 = -1;
char *token, *l_params;
struct rte_event_eth_rx_adapter_queue_stats q_stats;
@@ -3377,19 +3409,20 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
/* Get Rx adapter ID from parameter string */
l_params = strdup(params);
+ if (l_params == NULL)
+ return -ENOMEM;
token = strtok(l_params, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
rx_adapter_id = 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, -EINVAL);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get device ID from parameter string */
eth_dev_id = 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);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get Rx queue ID from parameter string */
@@ -3397,5 +3430,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
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);
- return -EINVAL;
+ ret = -EINVAL;
+ goto error;
}
@@ -3404,4 +3438,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
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,
@@ -3422,4 +3458,8 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
return 0;
+
+error:
+ free(l_params);
+ return ret;
}
@@ -3431,5 +3471,5 @@ 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 = -1;
char *token, *l_params;
@@ -3439,19 +3479,20 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
/* Get Rx adapter ID from parameter string */
l_params = strdup(params);
+ if (l_params == NULL)
+ return -ENOMEM;
token = strtok(l_params, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
rx_adapter_id = 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, -EINVAL);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get device ID from parameter string */
eth_dev_id = 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);
token = strtok(NULL, ",");
- if (token == NULL || strlen(token) == 0 || !isdigit(*token))
- return -1;
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
/* Get Rx queue ID from parameter string */
@@ -3459,5 +3500,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
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);
- return -EINVAL;
+ ret = -EINVAL;
+ goto error;
}
@@ -3466,4 +3508,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
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,
@@ -3475,4 +3519,8 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
return 0;
+
+error:
+ free(l_params);
+ return ret;
}
--
2.34.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2022-03-01 10:41:01.906616705 +0000
+++ 0019-eventdev-eth_rx-fix-parameters-parsing-memory-leak.patch 2022-03-01 10:41:01.256244088 +0000
@@ -1 +1 @@
-From 74b034ff817239b1a5dcf4dfd7d33ccd5684996a Mon Sep 17 00:00:00 2001
+From 529f3a735e4eb837049e340c1334ea6a6355397b Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 74b034ff817239b1a5dcf4dfd7d33ccd5684996a ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -21 +22 @@
-index ae1e260c08..4da6f1ff90 100644
+index f946137b25..ce94999738 100644
@@ -53 +54 @@
-@@ -3324,5 +3348,5 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
+@@ -3304,5 +3328,5 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
@@ -60 +61 @@
-@@ -3333,19 +3357,20 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
+@@ -3313,19 +3337,20 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
@@ -87 +88 @@
-@@ -3353,5 +3378,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
+@@ -3333,5 +3358,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
@@ -95 +96 @@
-@@ -3360,4 +3386,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
+@@ -3340,4 +3366,6 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
@@ -102 +103 @@
-@@ -3379,4 +3407,8 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
+@@ -3359,4 +3387,8 @@ handle_rxa_get_queue_conf(const char *cmd __rte_unused,
@@ -111 +112 @@
-@@ -3388,5 +3420,5 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+@@ -3368,5 +3400,5 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
@@ -118 +119 @@
-@@ -3397,19 +3429,20 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+@@ -3377,19 +3409,20 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
@@ -145 +146 @@
-@@ -3417,5 +3450,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+@@ -3397,5 +3430,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
@@ -153 +154 @@
-@@ -3424,4 +3458,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+@@ -3404,4 +3438,6 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
@@ -160 +161 @@
-@@ -3442,4 +3478,8 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+@@ -3422,4 +3458,8 @@ handle_rxa_get_queue_stats(const char *cmd __rte_unused,
@@ -169 +170 @@
-@@ -3451,5 +3491,5 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+@@ -3431,5 +3471,5 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
@@ -176 +177 @@
-@@ -3459,19 +3499,20 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+@@ -3439,19 +3479,20 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
@@ -203 +204 @@
-@@ -3479,5 +3520,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+@@ -3459,5 +3500,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
@@ -211 +212 @@
-@@ -3486,4 +3528,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+@@ -3466,4 +3508,6 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
@@ -218 +219 @@
-@@ -3495,4 +3539,8 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+@@ -3475,4 +3519,8 @@ handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
More information about the stable
mailing list