staging: vchiq: Fix list_for_each exit tests
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 6 Oct 2020 13:47:48 +0000 (16:47 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 Oct 2020 16:58:47 +0000 (18:58 +0200)
commit8750de90ac28d646f6a57f6d23d9997aa685dffd
treeb26afc73cc30377abbc75d79b9d17d5e39353097
parent6c75a92a0065a009429cec2c69f922f07cbbcd1e
staging: vchiq: Fix list_for_each exit tests

After a list_for_each_entry() loop, the list iterator is always non-NULL
so these conditions don't work.  If the "waiter" is not found then this
results in an out of bounds access.

I have fixed it by introducing a new "found" variable.  In one case, I
used an else statement for readability.

Fixes: 46e4b9ec4fa4 ("staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20201006134748.GA2076872@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c