arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261)
From: Dan Carpenter
Date: Sat Feb 27 2021 - 04:32:14 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8b83369ddcb3fb9cab5c1088987ce477565bb630
commit: 97ef275077932c65b1b8ec5022abd737a9fbf3e0 powerpc/xive: Fix xmon support on the PowerNV platform
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@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
smatch warnings:
arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261)
vim +/d +279 arch/powerpc/sysdev/xive/common.c
5896163f7f91c05 Cédric Le Goater 2019-09-10 259 int xmon_xive_get_irq_config(u32 hw_irq, struct irq_data *d)
b4868ff55d082bc Cédric Le Goater 2019-08-14 260 {
97ef275077932c6 Cédric Le Goater 2020-03-06 @261 struct irq_chip *chip = irq_data_get_irq_chip(d);
^
Dereferenced inside function
5896163f7f91c05 Cédric Le Goater 2019-09-10 262 int rc;
5896163f7f91c05 Cédric Le Goater 2019-09-10 263 u32 target;
5896163f7f91c05 Cédric Le Goater 2019-09-10 264 u8 prio;
5896163f7f91c05 Cédric Le Goater 2019-09-10 265 u32 lirq;
5896163f7f91c05 Cédric Le Goater 2019-09-10 266
97ef275077932c6 Cédric Le Goater 2020-03-06 267 if (!is_xive_irq(chip))
97ef275077932c6 Cédric Le Goater 2020-03-06 268 return -EINVAL;
97ef275077932c6 Cédric Le Goater 2020-03-06 269
5896163f7f91c05 Cédric Le Goater 2019-09-10 270 rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq);
5896163f7f91c05 Cédric Le Goater 2019-09-10 271 if (rc) {
5896163f7f91c05 Cédric Le Goater 2019-09-10 272 xmon_printf("IRQ 0x%08x : no config rc=%d\n", hw_irq, rc);
5896163f7f91c05 Cédric Le Goater 2019-09-10 273 return rc;
5896163f7f91c05 Cédric Le Goater 2019-09-10 274 }
5896163f7f91c05 Cédric Le Goater 2019-09-10 275
5896163f7f91c05 Cédric Le Goater 2019-09-10 276 xmon_printf("IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
5896163f7f91c05 Cédric Le Goater 2019-09-10 277 hw_irq, target, prio, lirq);
5896163f7f91c05 Cédric Le Goater 2019-09-10 278
5896163f7f91c05 Cédric Le Goater 2019-09-10 @279 if (d) {
^^^^^^
Checked too late
5896163f7f91c05 Cédric Le Goater 2019-09-10 280 struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
5896163f7f91c05 Cédric Le Goater 2019-09-10 281 u64 val = xive_esb_read(xd, XIVE_ESB_GET);
5896163f7f91c05 Cédric Le Goater 2019-09-10 282
5896163f7f91c05 Cédric Le Goater 2019-09-10 283 xmon_printf("PQ=%c%c",
5896163f7f91c05 Cédric Le Goater 2019-09-10 284 val & XIVE_ESB_VAL_P ? 'P' : '-',
5896163f7f91c05 Cédric Le Goater 2019-09-10 285 val & XIVE_ESB_VAL_Q ? 'Q' : '-');
5896163f7f91c05 Cédric Le Goater 2019-09-10 286 }
5896163f7f91c05 Cédric Le Goater 2019-09-10 287
5896163f7f91c05 Cédric Le Goater 2019-09-10 288 xmon_printf("\n");
5896163f7f91c05 Cédric Le Goater 2019-09-10 289 return 0;
b4868ff55d082bc Cédric Le Goater 2019-08-14 290 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip