Re: [PATCH] squashfs: Improve error handling in squashfs_decompressor_create()

From: Phillip Lougher
Date: Sun Jan 07 2024 - 14:30:55 EST


> On 30/12/2023 09:55 GMT Markus Elfring <markus.elfring@xxxxxx> wrote:
>
>
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Fri, 29 Dec 2023 21:30:26 +0100
>
> The kfree() function was called in two cases by
> the squashfs_decompressor_create() function during error handling
> even if the passed variable contained a null pointer.
> This issue was detected by using the Coccinelle software.
>
> * Thus return directly after a call of the function “kzalloc” failed
> at the beginning.
>
> * Use another label.
>
> * Move an error code assignment into an if branch.
>
> * Delete an initialisation (for the variable “decomp_strm”)
> which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>

As mentioned in this thread (and many others)

https://lore.kernel.org/all/20240104204032.GN31813@xxxxxxxxxx/

calling Kfree with a NULL pointer is perfectly valid.

So like most others I'm going to ignore this patch.

Cheers

Phillip