Skip to content

Commit 2012a9e

Browse files
Xiaomeng Tongwilldeacon
authored andcommitted
perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
The bug is here: return cluster; The list iterator value 'cluster' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found. To fix the bug, return 'cluster' when found, otherwise return NULL. Cc: stable@vger.kernel.org Fixes: 21bdbb7 ("perf: add qcom l2 cache perf events driver") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Link: https://lore.kernel.org/r/20220327055733.4070-1-xiam0nd.tong@gmail.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 4dfa1f3 commit 2012a9e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/perf/qcom_l2_pmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ static struct cluster_pmu *l2_cache_associate_cpu_with_cluster(
736736
{
737737
u64 mpidr;
738738
int cpu_cluster_id;
739-
struct cluster_pmu *cluster = NULL;
739+
struct cluster_pmu *cluster;
740740

741741
/*
742742
* This assumes that the cluster_id is in MPIDR[aff1] for
@@ -758,10 +758,10 @@ static struct cluster_pmu *l2_cache_associate_cpu_with_cluster(
758758
cluster->cluster_id);
759759
cpumask_set_cpu(cpu, &cluster->cluster_cpus);
760760
*per_cpu_ptr(l2cache_pmu->pmu_cluster, cpu) = cluster;
761-
break;
761+
return cluster;
762762
}
763763

764-
return cluster;
764+
return NULL;
765765
}
766766

767767
static int l2cache_pmu_online_cpu(unsigned int cpu, struct hlist_node *node)

0 commit comments

Comments
 (0)