firmware: arm_scmi: Fix list protocols enumeration in the base protocol
authorCristian Marussi <cristian.marussi@arm.com>
Wed, 30 Mar 2022 15:05:32 +0000 (16:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:08 +0000 (10:23 +0200)
commit98342148a8cd242855d7e257f298c966c96dba9f
treeb2459d4bbd2ba863dec707e627c8f8a34593f516
parentcff2553569f3afe8598f9556b17be3071decaf0b
firmware: arm_scmi: Fix list protocols enumeration in the base protocol

[ Upstream commit 8009120e0354a67068e920eb10dce532391361d0 ]

While enumerating protocols implemented by the SCMI platform using
BASE_DISCOVER_LIST_PROTOCOLS, the number of returned protocols is
currently validated in an improper way since the check employs a sum
between unsigned integers that could overflow and cause the check itself
to be silently bypassed if the returned value 'loop_num_ret' is big
enough.

Fix the validation avoiding the addition.

Link: https://lore.kernel.org/r/20220330150551.2573938-4-cristian.marussi@arm.com
Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/arm_scmi/base.c