Re: [PATCH] of: dynamic: Fix potential memory leak in of_changeset_action()

From: Geert Uytterhoeven
Date: Fri Sep 08 2023 - 03:16:44 EST


On Fri, Sep 8, 2023 at 9:03 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> Smatch complains that the error path where "action" is invalid leaks
> the "ce" allocation:
> drivers/of/dynamic.c:935 of_changeset_action()
> warn: possible memory leak of 'ce'
>
> Fix this by doing the validation before the allocation.
>
> Fixes: 914d9d831e61 ("of: dynamic: Refactor action prints to not use "%pOF" inside devtree_lock")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/r/202309011059.EOdr4im9-lkp@xxxxxxxxx/
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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