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/[email protected]/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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Link: https://lore.kernel.org/r/[email protected]/
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