Skip to content

Commit

Permalink
of/irq: Avoid calling list_first_entry() for empty list
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Grant Likely committed Jul 22, 2013
1 parent cfd1ee3 commit c0cdfaa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/of/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c0cdfaa

Please sign in to comment.