boot: menu: Do not dereference pointer if pointer is NULL
PATCH v2 1/1 boot: menu: Do not dereference pointer if pointer is NULL
scene_obj_find can return NULL but this is not checked for before the return is dereferenced. Add a NULL check.
This issue was found by Smatch.
Also add a NULL check for str.
---
Changes in v2:
- rebase to -next
- Add a NULL check for str
- Link to v1: https://lore.kernel.org/r/[email protected]
--- boot/scene_menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
boot/scene_menu.c +3 -2
@@ -571,14 +571,15 @@ int scene_menu_display(struct scene_obj_menu *menu)return log_msg_ret ("txt" , -EINVAL ); str =expo_get_str (exp, txt->gen.str_id); -printf ("%s\n\n" , str); +printf ("%s\n\n" , str ? str :"" ); }if (list_empty (&menu->item_head))return 0 ; pointer =scene_obj_find (scn, menu->pointer_id,SCENEOBJT_TEXT ); - pstr =expo_get_str (scn->expo, pointer->gen.str_id); +if (pointer) + pstr =expo_get_str (scn->expo, pointer->gen.str_id);list_for_each_entry (item, &menu->item_head, sibling) {struct scene_obj_txt *key =NULL , *label =NULL ;
---
base-commit: 5ab660663ded12cd6e063933016d27c9eafda2f3
change-id: 20250630-scene_menu_fix-60640ea67c20
Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
Quoted 8 lines · Andrew Goodbody
scene_obj_findcan return NULL but this is not checked for before the return is dereferenced. Add a NULL check.This issue was found by Smatch.
Also add a NULL check for str.
Signed-off-by Andrew Goodbody <[email protected]>
Signature · 1 line
Tom
Quoted 8 lines · Andrew Goodbody
scene_obj_findcan return NULL but this is not checked for before the return is dereferenced. Add a NULL check.This issue was found by Smatch.
Also add a NULL check for str.
[...]
Applied to u-boot/master, thanks!
[1/1] boot: menu: Do not dereference pointer if pointer is NULL
commit: 074e05952705972072f52128cf2e3ec2d8f35de6
Signature · 1 line
Tom