]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: PPC: Book3S HV: fix incorrect NULL check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Thu, 14 Apr 2022 06:21:03 +0000 (14:21 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 06:48:54 +0000 (08:48 +0200)
commit558ecc747ccf60ce3fc7b5603a0f6a6ccfb9d9ef
tree4789335a7a8dc63351aa0f62a8ac1d1c647915ac
parent04e4a11dc723c52db7a36dc58f0d69ce6426f8f0
KVM: PPC: Book3S HV: fix incorrect NULL check on list iterator

commit 300981abddcb13f8f06ad58f52358b53a8096775 upstream.

The bug is here:
if (!p)
                return ret;

The list iterator value 'p' 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, Use a new value 'iter' as the list iterator, while use
the old value 'p' as a dedicated variable to point to the found element.

Fixes: dfaa973ae960 ("KVM: PPC: Book3S HV: In H_SVM_INIT_DONE, migrate remaining normal-GFNs to secure-GFNs")
Cc: stable@vger.kernel.org # v5.9+
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220414062103.8153-1-xiam0nd.tong@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_hv_uvmem.c