[PATCH] um: vector: Fix memory leak in vector_config

Anton Ivanov anton.ivanov at cambridgegreys.com
Tue Jan 3 02:28:41 PST 2023


On 03/01/2023 08:00, Geert Uytterhoeven wrote:
> Hi Miaoqian,
>
> On Thu, Dec 29, 2022 at 8:53 AM Miaoqian Lin <linmq006 at gmail.com> wrote:
>> kstrdup() return newly allocated copy of the string.
>> Call kfree() to release the memory when after use.
>>
>> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
>> Signed-off-by: Miaoqian Lin <linmq006 at gmail.com>
> Thanks for your patch!
>
>> --- a/arch/um/drivers/vector_kern.c
>> +++ b/arch/um/drivers/vector_kern.c
>> @@ -765,6 +765,7 @@ static int vector_config(char *str, char **error_out)
>>
>>          parsed = uml_parse_vector_ifspec(params);
>>
>> +       kfree(params);
> Are you sure the memory pointed to by "params" is no longer used?
> "parsed" seems to contain pointers pointing to (parts of) the string
> pointed to by "params", so it cannot be freed.

+1.

I was just about to send the same comment.

>
>>          if (parsed == NULL) {
>>                  *error_out = "vector_config failed to parse parameters";
>>                  return -EINVAL;
> Gr{oetje,eeting}s,
>
>                          Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
>
> 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
>
-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/




More information about the linux-um mailing list