All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: drivers/perf/arm_cspmu/arm_cspmu.c:1075 arm_cspmu_find_cpu_container() warn: variable dereferenced before check 'cpu_dev' (see line 1073)
Date: Sun, 19 Feb 2023 12:54:17 +0800	[thread overview]
Message-ID: <202302191227.kc0V8fM7-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Besar Wicaksono <bwicaksono@nvidia.com>
CC: Will Deacon <will@kernel.org>
CC: Suzuki K Poulose <suzuki.poulose@arm.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   925cf0457d7e62ce08878ffb789189ac08ca8677
commit: e37dfd65731dc4f001fa7dfa7f705e6840017d5a perf: arm_cspmu: Add support for ARM CoreSight PMU driver
date:   3 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 3 months ago
config: arm64-randconfig-m031-20230219 (https://download.01.org/0day-ci/archive/20230219/202302191227.kc0V8fM7-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202302191227.kc0V8fM7-lkp@intel.com/

smatch warnings:
drivers/perf/arm_cspmu/arm_cspmu.c:1075 arm_cspmu_find_cpu_container() warn: variable dereferenced before check 'cpu_dev' (see line 1073)

vim +/cpu_dev +1075 drivers/perf/arm_cspmu/arm_cspmu.c

e37dfd65731dc4 Besar Wicaksono 2022-11-11  1068  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1069  static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1070  {
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1071  	u32 acpi_uid;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1072  	struct device *cpu_dev = get_cpu_device(cpu);
e37dfd65731dc4 Besar Wicaksono 2022-11-11 @1073  	struct acpi_device *acpi_dev = ACPI_COMPANION(cpu_dev);
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1074  
e37dfd65731dc4 Besar Wicaksono 2022-11-11 @1075  	if (!cpu_dev)
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1076  		return -ENODEV;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1077  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1078  	while (acpi_dev) {
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1079  		if (!strcmp(acpi_device_hid(acpi_dev),
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1080  			    ACPI_PROCESSOR_CONTAINER_HID) &&
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1081  		    !kstrtouint(acpi_device_uid(acpi_dev), 0, &acpi_uid) &&
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1082  		    acpi_uid == container_uid)
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1083  			return 0;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1084  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1085  		acpi_dev = acpi_dev_parent(acpi_dev);
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1086  	}
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1087  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1088  	return -ENODEV;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1089  }
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1090  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Besar Wicaksono <bwicaksono@nvidia.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
	Suzuki K Poulose <suzuki.poulose@arm.com>
Subject: drivers/perf/arm_cspmu/arm_cspmu.c:1075 arm_cspmu_find_cpu_container() warn: variable dereferenced before check 'cpu_dev' (see line 1073)
Date: Wed, 22 Feb 2023 16:53:53 +0300	[thread overview]
Message-ID: <202302191227.kc0V8fM7-lkp@intel.com> (raw)
Message-ID: <20230222135353.-HVUOBh2l6xDRYslHJ-i6zsI417w_bgIQCv9QIhDFw8@z> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   925cf0457d7e62ce08878ffb789189ac08ca8677
commit: e37dfd65731dc4f001fa7dfa7f705e6840017d5a perf: arm_cspmu: Add support for ARM CoreSight PMU driver
config: arm64-randconfig-m031-20230219 (https://download.01.org/0day-ci/archive/20230219/202302191227.kc0V8fM7-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202302191227.kc0V8fM7-lkp@intel.com/

smatch warnings:
drivers/perf/arm_cspmu/arm_cspmu.c:1075 arm_cspmu_find_cpu_container() warn: variable dereferenced before check 'cpu_dev' (see line 1073)

vim +/cpu_dev +1075 drivers/perf/arm_cspmu/arm_cspmu.c

e37dfd65731dc4 Besar Wicaksono 2022-11-11  1069  static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1070  {
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1071  	u32 acpi_uid;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1072  	struct device *cpu_dev = get_cpu_device(cpu);
e37dfd65731dc4 Besar Wicaksono 2022-11-11 @1073  	struct acpi_device *acpi_dev = ACPI_COMPANION(cpu_dev);
                                                                                                      ^^^^^^^
Dereference

e37dfd65731dc4 Besar Wicaksono 2022-11-11  1074  
e37dfd65731dc4 Besar Wicaksono 2022-11-11 @1075  	if (!cpu_dev)
                                                             ^^^^^^^
Checked too late.

e37dfd65731dc4 Besar Wicaksono 2022-11-11  1076  		return -ENODEV;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1077  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1078  	while (acpi_dev) {
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1079  		if (!strcmp(acpi_device_hid(acpi_dev),
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1080  			    ACPI_PROCESSOR_CONTAINER_HID) &&
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1081  		    !kstrtouint(acpi_device_uid(acpi_dev), 0, &acpi_uid) &&
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1082  		    acpi_uid == container_uid)
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1083  			return 0;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1084  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1085  		acpi_dev = acpi_dev_parent(acpi_dev);
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1086  	}
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1087  
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1088  	return -ENODEV;
e37dfd65731dc4 Besar Wicaksono 2022-11-11  1089  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


             reply	other threads:[~2023-02-19  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-19  4:54 kernel test robot [this message]
2023-02-22 13:53 ` drivers/perf/arm_cspmu/arm_cspmu.c:1075 arm_cspmu_find_cpu_container() warn: variable dereferenced before check 'cpu_dev' (see line 1073) Dan Carpenter

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=202302191227.kc0V8fM7-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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.