mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 23:59:33 -04:00
tools: ynl: check for null ptr on dump free
Static analysis detected code paths where freeing a dump list after early errors when creating the corresponding dump list like in ynl_exec_dump() can result in a null pointer dereference since the first node in the ynl_dump_state would still be zero initialized. To prevent this potential problem updated the ynl c generation script to check for a NULL pointer before continuing to free the nodes in a dump list. Signed-off-by: Thaison Phan <thaisonphan@google.com> Link: https://patch.msgid.link/20260807171500.7188-2-thaisonphan@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
30dbc21f63
commit
7c62c481bb
@@ -2747,6 +2747,9 @@ def print_dump_type_free(ri):
|
||||
ri.cw.block_start()
|
||||
ri.cw.p(f"{sub_type} *next = rsp;")
|
||||
ri.cw.nl()
|
||||
ri.cw.p('if (!next)')
|
||||
ri.cw.p('return;')
|
||||
ri.cw.nl()
|
||||
ri.cw.block_start(line='while ((void *)next != YNL_LIST_END)')
|
||||
_free_type_members_iter(ri, ri.struct['reply'])
|
||||
ri.cw.p('rsp = next;')
|
||||
|
||||
Reference in New Issue
Block a user