diff mbox series

perf: arm_cspmu: Fix compiler warning

Message ID 20230301225657.30211-1-bwicaksono@nvidia.com (mailing list archive)
State New, archived
Headers show
Series perf: arm_cspmu: Fix compiler warning | expand

Commit Message

Besar Wicaksono March 1, 2023, 10:56 p.m. UTC
Fix following compiler warning message
  | 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)

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/
Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>
---
 drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


base-commit: 7f7a8831520f12a3cf894b0627641fad33971221

Comments

Suzuki K Poulose March 2, 2023, 12:01 p.m. UTC | #1
On 01/03/2023 22:56, Besar Wicaksono wrote:
> Fix following compiler warning message
>    | 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)
> 
> 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/
> Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>

> ---
>   drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
> index e31302ab7e37..a3f1c410b417 100644
> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
> @@ -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
Randy Dunlap March 2, 2023, 4:34 p.m. UTC | #2
On 3/2/23 04:01, Suzuki K Poulose wrote:
> On 01/03/2023 22:56, Besar Wicaksono wrote:
>> Fix following compiler warning message
>>    | 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)
>>
>> 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/
>> Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com>
> 
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>

in Subject:, s/compiler/smatch/

>> ---
>>   drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
>> index e31302ab7e37..a3f1c410b417 100644
>> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
>> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
>> @@ -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
>
diff mbox series

Patch

diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index e31302ab7e37..a3f1c410b417 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -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) &&