Skip to contentSkip to conversation

perf: arm_cspmu: Fix variable dereference warning

PATCH Applied Besar Wicaksono 3 participants 3 messages Mar 2, 2023 – Mar 27, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf: arm_cspmu: Fix variable dereference warning

Fix warning message from smatch tool:

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

---

Changes from v1:
* Update commit subject and description
* Added Reviewed-by from Suzuki
v1: https://lore.kernel.org/linux-arm-kernel/[email protected]/T/#u

---
 drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/perf/arm_cspmu/arm_cspmu.c +4 -2
index e31302ab7e37..a3f1c410b417 100644
@@ -1078,12 +1078,14 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)
 static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
 {
 	u32 acpi_uid;
-	struct device *cpu_dev = get_cpu_device(cpu);
-	struct acpi_device *acpi_dev = ACPI_COMPANION(cpu_dev);
+	struct device *cpu_dev;
+	struct acpi_device *acpi_dev;
 
+	cpu_dev = get_cpu_device(cpu);
 	if (!cpu_dev)
 		return -ENODEV;
 
+	acpi_dev = ACPI_COMPANION(cpu_dev);
 	while (acpi_dev) {
 		if (!strcmp(acpi_device_hid(acpi_dev),
 			    ACPI_PROCESSOR_CONTAINER_HID) &&

base-commit: 7f7a8831520f12a3cf894b0627641fad33971221

Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Besar Wicaksono

Fix warning message from smatch tool:

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

Thanks.

Quoted 34 lines

---

Changes from v1:
* Update commit subject and description
* Added Reviewed-by from Suzuki
v1: https://lore.kernel.org/linux-arm-kernel/[email protected]/T/#u

---
 drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/perf/arm_cspmu/arm_cspmu.c +4 -2
index e31302ab7e37..a3f1c410b417 100644
@@ -1078,12 +1078,14 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)
 static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
 {
 	u32 acpi_uid;
-	struct device *cpu_dev = get_cpu_device(cpu);
-	struct acpi_device *acpi_dev = ACPI_COMPANION(cpu_dev);
+	struct device *cpu_dev;
+	struct acpi_device *acpi_dev;
 
+	cpu_dev = get_cpu_device(cpu);
 	if (!cpu_dev)
 		return -ENODEV;
 
+	acpi_dev = ACPI_COMPANION(cpu_dev);
 	while (acpi_dev) {
 		if (!strcmp(acpi_device_hid(acpi_dev),
 			    ACPI_PROCESSOR_CONTAINER_HID) &&

base-commit: 7f7a8831520f12a3cf894b0627641fad33971221

Signature · 1 line
~Randy
maintainer Applied
#2 lore raw
In reply to Besar Wicaksono
Quoted 6 lines · Besar Wicaksono

Fix warning message from smatch tool:

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

Applied to will (for-next/perf), thanks!

[1/1] perf: arm_cspmu: Fix variable dereference warning

      https://git.kernel.org/will/c/16e15834659e

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev