[2/3] event/cnxk: fix memory leak

Message ID 20220212123948.3394407-2-gmuthukrishn@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [1/3] event/cnxk: fix incompatible casting of variables |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan Feb. 12, 2022, 12:39 p.m. UTC
  Fix memory leaks reported in coverity scan.

Fixes: 8a3d58c189f ("event/cnxk: add option to control timer adapters")
Coverity issue: 374990 374991

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/event/cnxk/cnxk_tim_evdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c b/drivers/event/cnxk/cnxk_tim_evdev.c
index 4d22ac6ac3..af67235503 100644
--- a/drivers/event/cnxk/cnxk_tim_evdev.c
+++ b/drivers/event/cnxk/cnxk_tim_evdev.c
@@ -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);
 }