Skip to contentSkip to conversation

um: vector: Fix memory leak in vector_config

PATCH In review Miaoqian Lin 3 participants 3 messages Jan 4, 2023 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 um: vector: Fix memory leak in vector_config

kstrdup() return newly allocated copy of the string.
Call kfree() to release the memory when uml_parse_vector_ifspec() fails.

Fixes 49da7e64f33e ("High Performance UML Vector Network Driver")

---
changes in v2:
- only call kfree() when uml_parse_vector_ifspec() fails.

---
 arch/um/drivers/vector_kern.c | 1 +
 1 file changed, 1 insertion(+)
arch/um/drivers/vector_kern.c +1 -0
index ded7c47d2fbe..131b7cb29576 100644
@@ -767,6 +767,7 @@ static int vector_config(char *str, char **error_out)
 
 	if (parsed == NULL) {
 		*error_out = "vector_config failed to parse parameters";
+		kfree(params);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.25.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 17 lines · Miaoqian Lin

kstrdup() return newly allocated copy of the string.
Call kfree() to release the memory when uml_parse_vector_ifspec() fails.

Fixes 49da7e64f33e ("High Performance UML Vector Network Driver")

---
changes in v2:
- only call kfree() when uml_parse_vector_ifspec() fails.

---
  arch/um/drivers/vector_kern.c | 1 +
  1 file changed, 1 insertion(+)
arch/um/drivers/vector_kern.c +0 -0
index ded7c47d2fbe..131b7cb29576 100644

arch/um/drivers/vector_kern.c static int vector_config(char *str, char **error_out) · line 773

Quoted 7 lines
arch/um/drivers/vector_kern.c +1 -0
@@ -767,6 +767,7 @@ static int vector_config(char *str, char **error_out)
 
  	if (parsed == NULL) {
  		*error_out = "vector_config failed to parse parameters";
+		kfree(params);
  		return -EINVAL;
  	}
 
Signature · 3 lines
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
Reviewed-by on v2 1/1
#2 lore raw
In reply to Miaoqian Lin
Quoted 8 lines · Miaoqian Lin

kstrdup() return newly allocated copy of the string.
Call kfree() to release the memory when uml_parse_vector_ifspec() fails.

Fixes 49da7e64f33e ("High Performance UML Vector Network Driver")

---
changes in v2:
- only call kfree() when uml_parse_vector_ifspec() fails.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds