[v2,15/16] examples/qos_sched: fix memory leak when parse args
Checks
Commit Message
Should free the memory which allocated by strdup().
Fixes: 035b6a4f4bba ("examples/qos_sched: fix out-of-bounds option parsing")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
examples/qos_sched/args.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -103,8 +103,10 @@ app_parse_opt_vals(const char *conf_str, char separator, uint32_t n_vals, uint32
n_tokens = rte_strsplit(string, strnlen(string, 32), tokens, n_vals, separator);
- if (n_tokens > MAX_OPT_VALUES)
+ if (n_tokens > MAX_OPT_VALUES) {
+ free(string);
return -1;
+ }
for (i = 0; i < n_tokens; i++)
opt_vals[i] = (uint32_t)atol(tokens[i]);