Re: [PATCH v2] crypto: asymmetric_keys: fix uninitialized pointers with free attribute
From: Krzysztof Kozlowski
Date: Sat Nov 22 2025 - 09:25:24 EST
On 11/11/2025 14:36, Ally Heev wrote:
> Uninitialized pointers with `__free` attribute can cause undefined
> behavior as the memory assigned randomly to the pointer is freed
> automatically when the pointer goes out of scope.
>
> crypto/asymmetric_keys doesn't have any bugs related to this as of now,
> but, it is better to initialize and assign pointers with `__free`
> attribute in one statement to ensure proper scope-based cleanup
>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
> Signed-off-by: Ally Heev <allyheev@xxxxxxxxx>
> ---
> Changes in v2:
> - moved declarations to the top and initialized them with NULL
Why? This is not the syntax we want for cleanup.h. Either initialize it
with proper constructor or don't use cleanup.h.
Best regards,
Krzysztof