]> git.proxmox.com Git - mirror_ubuntu-jammy-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)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:41:20 +0000 (14:41 +0200)
commit419247a0362e6ecc98dc846225696e8a8c4ba92d
tree35e2a4dcf9377d3fc7b25259fc9b4ddaf08951e1
parented1838b4dc8009913b5c21c0a536d373adc2c77c
perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator

BugLink: https://bugs.launchpad.net/bugs/1969107
commit 2012a9e279013933885983cbe0a5fe828052563b upstream.

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: 21bdbb7102ed ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 0309f053ce47721aed7987ad8048d7862235a61d)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/perf/qcom_l2_pmu.c