From 4b68bb0be33cbc61f91a08251f64d1c13c834c42 Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Fri, 21 Feb 2025 09:56:32 +0000 Subject: [PATCH] UPSTREAM: firmware: arm_ffa: Explicitly cast return value from NOTIFICATION_INFO_GET The return value ret.a2 is of type unsigned long and FFA_RET_NO_DATA is a negative value. Since the return value from the firmware can be just 32-bit even on 64-bit systems as FFA specification mentions it as int32 error code in w0 register, explicitly casting to s32 ensures correct sign interpretation when comparing against a signed error code FFA_RET_NO_DATA. Without casting, comparison between unsigned long and a negative constant could lead to unintended results due to type promotions. Fixes: 3522be48d82b ("firmware: arm_ffa: Implement the NOTIFICATION_INFO_GET interface") Reported-by: Andrei Homescu Message-Id: <20250221095633.506678-2-sudeep.holla@arm.com> Change-Id: I11f218090699f0a19d8fed7b0568cd1004575687 Signed-off-by: Sudeep Holla (cherry picked from commit 3e282f41585c4dd49b688bd6395fd6f21a57c9f7) Signed-off-by: Andrei Homescu Bug: 435501117 --- drivers/firmware/arm_ffa/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index da5f1bfabf25..c8b7389445fa 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -882,7 +882,7 @@ static void ffa_notification_info_get(void) }, &ret); if (ret.a0 != FFA_FN_NATIVE(SUCCESS) && ret.a0 != FFA_SUCCESS) { - if (ret.a2 != FFA_RET_NO_DATA) + if ((s32)ret.a2 != FFA_RET_NO_DATA) pr_err("Notification Info fetch failed: 0x%lx (0x%lx)", ret.a0, ret.a2); return;