event/cnxk: fix memory leaks
authorGowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Sat, 12 Feb 2022 12:39:47 +0000 (18:09 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 22 Feb 2022 09:49:48 +0000 (10:49 +0100)
Fix memory leaks reported by coverity scan in
cnxk_tim_parse_clk_list()  and cnxk_tim_parse_ring_ctl_list()
functions on not freeing strduped memory.

Coverity issue: 374990 374991
Fixes: 8a3d58c189f ("event/cnxk: add option to control timer adapters")
Cc: stable@dpdk.org
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
drivers/event/cnxk/cnxk_tim_evdev.c

index 4d22ac6..af67235 100644 (file)
@@ -560,7 +560,7 @@ cnxk_tim_parse_ring_ctl_list(const char *value, void *opaque)
        char *f = s;
 
        if (s == NULL || !strlen(s))
-               return;
+               goto free;
 
        while (*s) {
                if (*s == '[')
@@ -579,6 +579,7 @@ cnxk_tim_parse_ring_ctl_list(const char *value, void *opaque)
                s++;
        }
 
+free:
        free(f);
 }
 
@@ -607,7 +608,7 @@ cnxk_tim_parse_clk_list(const char *value, void *opaque)
        int i = 0;
 
        if (str == NULL || !strlen(str))
-               return;
+               goto free;
 
        tok = strtok(str, "-");
        while (tok != NULL && src[i] != ROC_TIM_CLK_SRC_INVALID) {
@@ -616,6 +617,7 @@ cnxk_tim_parse_clk_list(const char *value, void *opaque)
                i++;
        }
 
+free:
        free(str);
 }