Skip to content

Commit c0cdfaa

Browse files
AxelLinglikely
authored andcommitted
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 <axel.lin@ingics.com> Signed-off-by: Grant Likely <grant.likely@linaro.org>
1 parent cfd1ee3 commit c0cdfaa

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/of/irq.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,9 @@ void __init of_irq_init(const struct of_device_id *matches)
482482
}
483483

484484
/* Get the next pending parent that might have children */
485-
desc = list_first_entry(&intc_parent_list, typeof(*desc), list);
486-
if (list_empty(&intc_parent_list) || !desc) {
485+
desc = list_first_entry_or_null(&intc_parent_list,
486+
typeof(*desc), list);
487+
if (!desc) {
487488
pr_err("of_irq_init: children remain, but no parents\n");
488489
break;
489490
}

0 commit comments

Comments
 (0)