]> git.baikalelectronics.ru Git - kernel.git/commit
perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Sun, 27 Mar 2022 05:57:33 +0000 (13:57 +0800)
committerWill Deacon <will@kernel.org>
Mon, 4 Apr 2022 09:50:02 +0000 (10:50 +0100)
commit306a9097ef5b2acfe2417206277fc6d0ae25a7a1
tree8996fa1ac5b3a3b615dcf9bc5c42af1bead87836
parented751bbb4b04edf806229cf0f9c26082473a7d95
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: 25b82404a07a ("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>
drivers/perf/qcom_l2_pmu.c