Multiple threads calling the same function may cause condition
race issues, which often leads to abnormal behavior and can cause
more serious vulnerabilities such as abnormal termination, denial
of service, and compromised data integrity.

The strtok() is non-reentrant, it is better to replace it with a
reentrant version.

Fixes: 39b5ab60df30 ("dmadev: add telemetry")
Cc: sta...@dpdk.org

Signed-off-by: Jie Hai <haij...@huawei.com>
Acked-by: Chengwen Feng <fengcheng...@huawei.com>
---
 lib/dmadev/rte_dmadev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 4e5e420c82a5..e9c052304393 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -971,7 +971,7 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused,
        struct rte_dma_info dma_info;
        struct rte_dma_stats dma_stats;
        int dev_id, ret, vchan_id;
-       char *end_param;
+       char *end_param, *sp = NULL;
        const char *vchan_param;
 
        if (params == NULL || strlen(params) == 0 || !isdigit(*params))
@@ -990,7 +990,7 @@ dmadev_handle_dev_stats(const char *cmd __rte_unused,
        if (dma_info.nb_vchans == 1 && *end_param == '\0')
                vchan_id = 0;
        else {
-               vchan_param = strtok(end_param, ",");
+               vchan_param = strtok_s(end_param, ",", &sp);
                if (!vchan_param || strlen(vchan_param) == 0 || 
!isdigit(*vchan_param))
                        return -EINVAL;
 
-- 
2.30.0

Reply via email to