[PATCH v2 05/11] malloc: malloc_elem_join_adjacent_free can return null
Dmitry Kozlyuk
dmitry.kozliuk at gmail.com
Tue Nov 22 16:52:26 CET 2022
2022-11-21 17:32 (UTC-0500), okaya at kernel.org:
> From: Sinan Kaya <okaya at kernel.org>
>
> In malloc_heap_add_memory result of call to malloc_elem_join_adjacent_free
> is dereferenced here and may be null.
It may not:
"malloc_elem_join_adjacent_free()" never returns NULL by definition.
Would annotating "malloc_elem_join_adjacent_free()" result
(and maybe the argument too)
convince codeql that the check is not needed?
A comment to the series:
I'm against adding extra checks *only* to silence some tool,
not because they're overly defensive,
but because they misrepresent the code assumptions,
making the understanding harder.
Returning false if assumptions are broken is arguably no better then crashing,
because this means that either the internal state is inconsistent
or the caller has supplied invalid arguments (logical error up the stack).
More information about the dev
mailing list