Re: [PATCH] db: fix memory leak in kdb_setenv() when environment is full

From: Doug Anderson

Date: Tue Jun 16 2026 - 17:46:10 EST


Hi,

On Tue, Jun 16, 2026 at 9:42 AM Naveen Kumar Chaudhary
<naveen.osdev@xxxxxxxxx> wrote:
>
> When kdb_setenv() fails to find a free slot in __env[], the function
> returns KDB_ENVFULL without freeing the previously allocated string
> buffer 'ep', leaking memory on every failed call.
>
> Add the missing kfree(ep) before returning KDB_ENVFULL.
>
> Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@xxxxxxxxx>
> ---
> kernel/debug/kdb/kdb_main.c | 1 +
> 1 file changed, 1 insertion(+)

With the exception of the missing 'k' at the start of the subject
line, this looks good to me. Presumably it should have a "Fixes:" line
too:

Fixes: a30d4ff8193e ("kdb: remove usage of static environment buffer")

Aside from that:

Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>