devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of/irq: Avoid calling list_first_entry() for empty list
@ 2013-06-23  7:50 Axel Lin
  2013-07-20  5:35 ` Grant Likely
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2013-06-23  7:50 UTC (permalink / raw)
  To: Grant Likely
  Cc: Rob Herring, Stephen Warren, devicetree-discuss, linux-kernel

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>
---
 drivers/of/irq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index a3c1c5a..5c645c7 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -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;
 		}
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] of/irq: Avoid calling list_first_entry() for empty list
  2013-06-23  7:50 [PATCH] of/irq: Avoid calling list_first_entry() for empty list Axel Lin
@ 2013-07-20  5:35 ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2013-07-20  5:35 UTC (permalink / raw)
  To: Axel Lin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Stephen Warren,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring

On Sun, 23 Jun 2013 15:50:07 +0800, Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org> wrote:
> 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-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>

Applied, thanks.

g.

> ---
>  drivers/of/irq.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index a3c1c5a..5c645c7 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -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;
>  		}
> -- 
> 1.8.1.2
> 
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-20  5:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-23  7:50 [PATCH] of/irq: Avoid calling list_first_entry() for empty list Axel Lin
2013-07-20  5:35 ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).