Re: [PATCH v2] livepatch: Reorder to use before freeing a pointer

From: Petr Mladek
Date: Mon Mar 21 2022 - 09:24:15 EST


On Sat 2022-03-19 18:51:43, trix@xxxxxxxxxx wrote:
> From: Tom Rix <trix@xxxxxxxxxx>
>
> Clang static analysis reports this issue
> livepatch-shadow-fix1.c:113:2: warning: Use of
> memory after it is freed
> pr_info("%s: dummy @ %p, prevented leak @ %p\n",
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The pointer is freed in the previous statement.
> Reorder the pr_info to report before the free.
>
> Similar issue in livepatch-shadow-fix2.c
>
> Signed-off-by: Tom Rix <trix@xxxxxxxxxx>

Strictly speaking, the freed memory is not used.
pr_info() only prints the address.

Anyway, I agree that the reordered code is cleaner.

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>

Best Regards,
Petr