Re: [PATCH] module: Fix use-after-free bug in read_file_mod_stats()

From: Luis Chamberlain
Date: Mon May 22 2023 - 17:21:53 EST


On Thu, Apr 27, 2023 at 10:59:33PM -0700, Harshit Mogalapalli wrote:
> Smatch warns:
> kernel/module/stats.c:394 read_file_mod_stats()
> warn: passing freed memory 'buf'
>
> We are passing 'buf' to simple_read_from_buffer() after freeing it.
>
> Fix this by changing the order of 'simple_read_from_buffer' and 'kfree'.
>
> Fixes: df3e764d8e5c ("module: add debug stats to help identify memory pressure")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx>
> ---

Queued up, thanks!

Luis