Skip to content

Commit

Permalink
perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
Browse files Browse the repository at this point in the history
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: [email protected]
Fixes: 21bdbb7 ("perf: add qcom l2 cache perf events driver")
Signed-off-by: Xiaomeng Tong <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Will Deacon <[email protected]>
  • Loading branch information
Xiaomeng Tong authored and willdeacon committed Apr 4, 2022
1 parent 4dfa1f3 commit 2012a9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/perf/qcom_l2_pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ static struct cluster_pmu *l2_cache_associate_cpu_with_cluster(
{
u64 mpidr;
int cpu_cluster_id;
struct cluster_pmu *cluster = NULL;
struct cluster_pmu *cluster;

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

return cluster;
return NULL;
}

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

0 comments on commit 2012a9e

Please sign in to comment.