Subject: Re: [PATCH v2 5/8] powerpc/xive: Drop check on irq_data in xive_core_debug_show()

From: Greg Kurz <[email-masked]>
Date: Tue, 9 Mar 2021 10:18:41 +0100

On Wed, 3 Mar 2021 18:48:54 +0100
Cédric Le Goater <[email-masked]> wrote:

> When looping on IRQ descriptor, irq_data is always valid.
> 
> Reported-by: kernel test robot <[email-masked]>
> Reported-by: Dan Carpenter <[email-masked]>
> Fixes: 930914b7d528 ("powerpc/xive: Add a debugfs file to dump internal XIVE state")
> Signed-off-by: Cédric Le Goater <[email-masked]>
> ---

Reviewed-by: Greg Kurz <[email-masked]>

>  arch/powerpc/sysdev/xive/common.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
> index 7581cb12bb53..60ebd6f4b31d 100644
> --- a/arch/powerpc/sysdev/xive/common.c
> +++ b/arch/powerpc/sysdev/xive/common.c
> @@ -1586,6 +1586,8 @@ static void xive_debug_show_irq(struct seq_file *m, struct irq_data *d)
>  	u32 target;
>  	u8 prio;
>  	u32 lirq;
> +	struct xive_irq_data *xd;
> +	u64 val;
>  
>  	rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq);
>  	if (rc) {
> @@ -1596,17 +1598,14 @@ static void xive_debug_show_irq(struct seq_file *m, struct irq_data *d)
>  	seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
>  		   hw_irq, target, prio, lirq);
>  
> -	if (d) {
> -		struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
> -		u64 val = xive_esb_read(xd, XIVE_ESB_GET);
> -
> -		seq_printf(m, "flags=%c%c%c PQ=%c%c",
> -			   xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
> -			   xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
> -			   xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
> -			   val & XIVE_ESB_VAL_P ? 'P' : '-',
> -			   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
> -	}
> +	xd = irq_data_get_irq_handler_data(d);
> +	val = xive_esb_read(xd, XIVE_ESB_GET);
> +	seq_printf(m, "flags=%c%c%c PQ=%c%c",
> +		   xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
> +		   xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
> +		   xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
> +		   val & XIVE_ESB_VAL_P ? 'P' : '-',
> +		   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
>  	seq_puts(m, "\n");
>  }
>