From: Sunil Kumar Kori Date: Tue, 12 Oct 2021 08:33:17 +0000 (+0530) Subject: app/testpmd: fix access to DSCP table entries X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b314a4a664266f691167c29de6bc5ce728346c02;p=dpdk.git app/testpmd: fix access to DSCP table entries During parsing of DSCP entries, memory is allocated and assigned to *dscp_table. Later on, same memory is accessed using *dscp_table[i++]. Due to higher precedence for array subscript, dscp_table[i++] will be executed first which actually does not point to the same memory which was allocated previously for DSCP table entries. Fixes: 459463ae6c26 ("app/testpmd: fix memory allocation for DSCP table") Cc: stable@dpdk.org Signed-off-by: Sunil Kumar Kori Reviewed-by: Ferruh Yigit --- diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index b5dcfdadcf..ad7ef6ad98 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -101,13 +101,13 @@ parse_dscp_table_entries(char *str, enum rte_color **dscp_table) while (1) { if (strcmp(token, "G") == 0 || strcmp(token, "g") == 0) - *dscp_table[i++] = RTE_COLOR_GREEN; + (*dscp_table)[i++] = RTE_COLOR_GREEN; else if (strcmp(token, "Y") == 0 || strcmp(token, "y") == 0) - *dscp_table[i++] = RTE_COLOR_YELLOW; + (*dscp_table)[i++] = RTE_COLOR_YELLOW; else if (strcmp(token, "R") == 0 || strcmp(token, "r") == 0) - *dscp_table[i++] = RTE_COLOR_RED; + (*dscp_table)[i++] = RTE_COLOR_RED; else { free(*dscp_table); return -1;