Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Axel Lin and committed by
Grant Likely
c0cdfaa0 cfd1ee3e

+3 -2
+3 -2
drivers/of/irq.c
··· 482 482 } 483 483 484 484 /* 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) { 487 488 pr_err("of_irq_init: children remain, but no parents\n"); 488 489 break; 489 490 }