Skip to content

Commit

Permalink
app/testpmd: fix access to DSCP table entries
Browse files Browse the repository at this point in the history
[ upstream commit b314a4a ]

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: 459463a ("app/testpmd: fix memory allocation for DSCP table")

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
SunilKumarKori authored and cpaelzer committed Nov 30, 2021
1 parent e3285b3 commit 9f2a1bc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/test-pmd/cmdline_mtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,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;
Expand Down

0 comments on commit 9f2a1bc

Please sign in to comment.