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)
committerMark Brown <broonie@kernel.org>
Mon, 16 Feb 2015 02:31:34 +0000 (11:31 +0900)
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>
(cherry picked from commit c0cdfaa0a5e7a346ac2f661f63f543cdc5f7cbbe)
Signed-off-by: Mark Brown <broonie@kernel.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;
                }