[PATCH] linux_compat: fix NULL pointer dereference in get_mem()
Tom Rini
trini at konsulko.com
Fri Feb 27 00:38:16 CET 2026
On Fri, Feb 27, 2026 at 12:27:28AM +0300, Anton Moryakov wrote:
> Add NULL check after memalign() call in get_mem() to prevent
> potential NULL pointer dereference (CWE-476).
>
> The function memalign() can return NULL on allocation failure.
> Dereferencing the returned pointer without checking for NULL
> may cause a crash in low-memory conditions.
>
> Changes:
> - Add NULL check after memalign() allocation
> - Return NULL on failure, consistent with function semantics
>
> This fixes the static analyzer warning:
> linux_compat.c:34: dereference of memalign return value without NULL check
>
> Reported-by: static analyzer Svace
> Signed-off-by: Anton Moryakov <ant.v.moryakov at gmail.com>
Reviewed-by: Tom Rini <trini at konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260226/d4d8712f/attachment.sig>
More information about the U-Boot
mailing list