Skip to content

Commit cecf6a5

Browse files
committed
firmware: arm_ffa: Explicitly cast return value from FFA_VERSION before comparison
The return value ver.a0 is unsigned long type and FFA_RET_NOT_SUPPORTED 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_NOT_SUPPORTED. Without casting, comparison between unsigned long and a negative constant could lead to unintended results due to type promotions. Fixes: 3bbfe98 ("firmware: arm_ffa: Add initial Arm FFA driver support") Reported-by: Andrei Homescu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 9472fe2 commit cecf6a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int ffa_version_check(u32 *version)
144144
.a0 = FFA_VERSION, .a1 = FFA_DRIVER_VERSION,
145145
}, &ver);
146146

147-
if (ver.a0 == FFA_RET_NOT_SUPPORTED) {
147+
if ((s32)ver.a0 == FFA_RET_NOT_SUPPORTED) {
148148
pr_info("FFA_VERSION returned not supported\n");
149149
return -EOPNOTSUPP;
150150
}

0 commit comments

Comments
 (0)