of/irq: Avoid calling list_first_entry() for empty list
PATCH 1/1 of/irq: Avoid calling list_first_entry() for empty list
list_first_entry() expects the list is not empty, we need to check if list is empty before calling list_first_entry(). Thus use list_first_entry_or_null() instead of list_first_entry().
Signed-off-by Axel Lin <[email protected]>
--- drivers/of/irq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/of/irq.c +3 -2
@@ -482,8 +482,9 @@ void __init of_irq_init(const struct of_device_id *matches) }/* Get the next pending parent that might have children */ - desc =list_first_entry (&intc_parent_list,typeof (*desc), list); -if (list_empty (&intc_parent_list) || !desc) { + desc =list_first_entry_or_null (&intc_parent_list, +typeof (*desc), list); +if (!desc) {pr_err ("of_irq_init: children remain, but no parents\n" );break ; }
Signature · 1 line
1.8.1.2
Grant Likely
AppliedQuoted 5 lines · Axel Lin
list_first_entry()expects the list is not empty, we need to check if list is empty before callinglist_first_entry(). Thus uselist_first_entry_or_null()instead oflist_first_entry().Signed-off-by Axel Lin <[email protected]>
Applied, thanks.
g.
Quoted 25 lines
--- drivers/of/irq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/of/irq.c +3
-2@@ -482,8 +482,9 @@ void __init of_irq_init(const struct of_device_id *matches) }/* Get the next pending parent that might have children */ - desc =list_first_entry (&intc_parent_list,typeof (*desc), list); -if (list_empty (&intc_parent_list) || !desc) { + desc =list_first_entry_or_null (&intc_parent_list, +typeof (*desc), list); +if (!desc) {pr_err ("of_irq_init: children remain, but no parents\n" );break ; }Signature · 1 line
1.8.1.2