of/irq: Avoid calling list_first_entry() for empty list
authorAxel Lin <axel.lin@ingics.com>
Sun, 23 Jun 2013 07:50:07 +0000 (15:50 +0800)
committerGrant Likely <grant.likely@linaro.org>
Mon, 22 Jul 2013 18:40:38 +0000 (19:40 +0100)
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>
drivers/of/irq.c

index a3c1c5aae6a9eaa5de0ecd0dd0335771ac8f7fab..5c645c7227b8983c9c36cf4fa25c5bccc7ba784f 100644 (file)
@@ -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;
                }