linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596)
@ 2021-02-27 15:03 Dan Carpenter
  2021-03-03 13:23 ` Cédric Le Goater
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-27 15:03 UTC (permalink / raw)
  To: kbuild, Cédric Le Goater
  Cc: lkp, kbuild-all, linux-kernel, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 3719 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   3fb6d0e00efc958d01c2f109c8453033a2d96796
commit: 930914b7d528fc6b0249bffc00564100bcf6ef75 powerpc/xive: Add a debugfs file to dump internal XIVE state
config: powerpc64-randconfig-m031-20210226 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596)

Old smatch warnings:
arch/powerpc/sysdev/xive/common.c:280 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 262)

vim +/d +1614 arch/powerpc/sysdev/xive/common.c

930914b7d528fc Cédric Le Goater 2020-03-06  1594  void xive_debug_show_irq(struct seq_file *m, u32 hw_irq, struct irq_data *d)
930914b7d528fc Cédric Le Goater 2020-03-06  1595  {
930914b7d528fc Cédric Le Goater 2020-03-06 @1596  	struct irq_chip *chip = irq_data_get_irq_chip(d);
                                                                                                      ^
Dereferenced inside function

930914b7d528fc Cédric Le Goater 2020-03-06  1597  	int rc;
930914b7d528fc Cédric Le Goater 2020-03-06  1598  	u32 target;
930914b7d528fc Cédric Le Goater 2020-03-06  1599  	u8 prio;
930914b7d528fc Cédric Le Goater 2020-03-06  1600  	u32 lirq;
930914b7d528fc Cédric Le Goater 2020-03-06  1601  
930914b7d528fc Cédric Le Goater 2020-03-06  1602  	if (!is_xive_irq(chip))
930914b7d528fc Cédric Le Goater 2020-03-06  1603  		return;
930914b7d528fc Cédric Le Goater 2020-03-06  1604  
930914b7d528fc Cédric Le Goater 2020-03-06  1605  	rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq);
930914b7d528fc Cédric Le Goater 2020-03-06  1606  	if (rc) {
930914b7d528fc Cédric Le Goater 2020-03-06  1607  		seq_printf(m, "IRQ 0x%08x : no config rc=%d\n", hw_irq, rc);
930914b7d528fc Cédric Le Goater 2020-03-06  1608  		return;
930914b7d528fc Cédric Le Goater 2020-03-06  1609  	}
930914b7d528fc Cédric Le Goater 2020-03-06  1610  
930914b7d528fc Cédric Le Goater 2020-03-06  1611  	seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
930914b7d528fc Cédric Le Goater 2020-03-06  1612  		   hw_irq, target, prio, lirq);
930914b7d528fc Cédric Le Goater 2020-03-06  1613  
930914b7d528fc Cédric Le Goater 2020-03-06 @1614  	if (d) {
                                                        ^^^^^^^^
Checked too late.

930914b7d528fc Cédric Le Goater 2020-03-06  1615  		struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
930914b7d528fc Cédric Le Goater 2020-03-06  1616  		u64 val = xive_esb_read(xd, XIVE_ESB_GET);
930914b7d528fc Cédric Le Goater 2020-03-06  1617  
930914b7d528fc Cédric Le Goater 2020-03-06  1618  		seq_printf(m, "flags=%c%c%c PQ=%c%c",
930914b7d528fc Cédric Le Goater 2020-03-06  1619  			   xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
930914b7d528fc Cédric Le Goater 2020-03-06  1620  			   xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
930914b7d528fc Cédric Le Goater 2020-03-06  1621  			   xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
930914b7d528fc Cédric Le Goater 2020-03-06  1622  			   val & XIVE_ESB_VAL_P ? 'P' : '-',
930914b7d528fc Cédric Le Goater 2020-03-06  1623  			   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
930914b7d528fc Cédric Le Goater 2020-03-06  1624  	}
930914b7d528fc Cédric Le Goater 2020-03-06  1625  	seq_puts(m, "\n");
930914b7d528fc Cédric Le Goater 2020-03-06  1626  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31970 bytes --]

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

* Re: arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596)
  2021-02-27 15:03 arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596) Dan Carpenter
@ 2021-03-03 13:23 ` Cédric Le Goater
  0 siblings, 0 replies; 2+ messages in thread
From: Cédric Le Goater @ 2021-03-03 13:23 UTC (permalink / raw)
  To: Dan Carpenter, kbuild
  Cc: lkp, kbuild-all, linux-kernel, Michael Ellerman, Greg Kurz

On 2/27/21 4:03 PM, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   3fb6d0e00efc958d01c2f109c8453033a2d96796
> commit: 930914b7d528fc6b0249bffc00564100bcf6ef75 powerpc/xive: Add a debugfs file to dump internal XIVE state
> config: powerpc64-randconfig-m031-20210226 (attached as .config)
> compiler: powerpc64-linux-gcc (GCC) 9.3.0
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> New smatch warnings:
> arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596)

This should be addressed by patch : 

  http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210209161936.377760-5-clg@kaod.org/

> Old smatch warnings:
> arch/powerpc/sysdev/xive/common.c:280 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 262)
This one needs a very similar fix which can come as a followup.

Thanks,

C.

> vim +/d +1614 arch/powerpc/sysdev/xive/common.c
> 
> 930914b7d528fc Cédric Le Goater 2020-03-06  1594  void xive_debug_show_irq(struct seq_file *m, u32 hw_irq, struct irq_data *d)
> 930914b7d528fc Cédric Le Goater 2020-03-06  1595  {
> 930914b7d528fc Cédric Le Goater 2020-03-06 @1596  	struct irq_chip *chip = irq_data_get_irq_chip(d);
>                                                                                                       ^
> Dereferenced inside function
> 
> 930914b7d528fc Cédric Le Goater 2020-03-06  1597  	int rc;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1598  	u32 target;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1599  	u8 prio;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1600  	u32 lirq;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1601  
> 930914b7d528fc Cédric Le Goater 2020-03-06  1602  	if (!is_xive_irq(chip))
> 930914b7d528fc Cédric Le Goater 2020-03-06  1603  		return;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1604  
> 930914b7d528fc Cédric Le Goater 2020-03-06  1605  	rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq);
> 930914b7d528fc Cédric Le Goater 2020-03-06  1606  	if (rc) {
> 930914b7d528fc Cédric Le Goater 2020-03-06  1607  		seq_printf(m, "IRQ 0x%08x : no config rc=%d\n", hw_irq, rc);
> 930914b7d528fc Cédric Le Goater 2020-03-06  1608  		return;
> 930914b7d528fc Cédric Le Goater 2020-03-06  1609  	}
> 930914b7d528fc Cédric Le Goater 2020-03-06  1610  
> 930914b7d528fc Cédric Le Goater 2020-03-06  1611  	seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
> 930914b7d528fc Cédric Le Goater 2020-03-06  1612  		   hw_irq, target, prio, lirq);
> 930914b7d528fc Cédric Le Goater 2020-03-06  1613  
> 930914b7d528fc Cédric Le Goater 2020-03-06 @1614  	if (d) {
>                                                         ^^^^^^^^
> Checked too late.
> 
> 930914b7d528fc Cédric Le Goater 2020-03-06  1615  		struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
> 930914b7d528fc Cédric Le Goater 2020-03-06  1616  		u64 val = xive_esb_read(xd, XIVE_ESB_GET);
> 930914b7d528fc Cédric Le Goater 2020-03-06  1617  
> 930914b7d528fc Cédric Le Goater 2020-03-06  1618  		seq_printf(m, "flags=%c%c%c PQ=%c%c",
> 930914b7d528fc Cédric Le Goater 2020-03-06  1619  			   xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
> 930914b7d528fc Cédric Le Goater 2020-03-06  1620  			   xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
> 930914b7d528fc Cédric Le Goater 2020-03-06  1621  			   xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
> 930914b7d528fc Cédric Le Goater 2020-03-06  1622  			   val & XIVE_ESB_VAL_P ? 'P' : '-',
> 930914b7d528fc Cédric Le Goater 2020-03-06  1623  			   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
> 930914b7d528fc Cédric Le Goater 2020-03-06  1624  	}
> 930914b7d528fc Cédric Le Goater 2020-03-06  1625  	seq_puts(m, "\n");
> 930914b7d528fc Cédric Le Goater 2020-03-06  1626  }
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 


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

end of thread, other threads:[~2021-03-03 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-27 15:03 arch/powerpc/sysdev/xive/common.c:1614 xive_debug_show_irq() warn: variable dereferenced before check 'd' (see line 1596) Dan Carpenter
2021-03-03 13:23 ` Cédric Le Goater

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).