All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261)
Date: Sat, 27 Feb 2021 12:30:50 +0300	[thread overview]
Message-ID: <20210227093050.GE2087@kadam> (raw)

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

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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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(a)lists.01.org

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

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261)
Date: Sat, 27 Feb 2021 12:30:50 +0300	[thread overview]
Message-ID: <20210227093050.GE2087@kadam> (raw)

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

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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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(a)lists.01.org

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

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, "Cédric Le Goater" <clg@kaod.org>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>, Greg Kurz <groug@kaod.org>
Subject: arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261)
Date: Sat, 27 Feb 2021 12:30:50 +0300	[thread overview]
Message-ID: <20210227093050.GE2087@kadam> (raw)

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

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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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@lists.01.org

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

             reply	other threads:[~2021-02-27  9:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-27  9:30 Dan Carpenter [this message]
2021-02-27  9:30 ` arch/powerpc/sysdev/xive/common.c:279 xmon_xive_get_irq_config() warn: variable dereferenced before check 'd' (see line 261) Dan Carpenter
2021-02-27  9:30 ` Dan Carpenter
2021-03-03 13:21 ` Cédric Le Goater
  -- strict thread matches above, loose matches on Subject: below --
2021-02-27  0:07 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210227093050.GE2087@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.