Skip to contentSkip to conversation

tee: optee: Fix unsigned comparison with less than zero

PATCH In review YueHaibing 2 participants 2 messages Feb 19, 2019

Subsystems (2)
lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 tee: optee: Fix unsigned comparison with less than zero

The return from the call to tee_client_invoke_func can be a negative error code however this is being assigned to an unsigned variable 'ret' hence the check is always false. Fix this by making 'ret' an int.

Detected by Coccinelle ("Unsigned expression compared with zero:
ret < 0")

Fixes c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
---
 drivers/tee/optee/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tee/optee/device.c +1 -1
index 5e4938b..1f22376 100644
@@ -34,7 +34,7 @@ static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
 static int get_devices(struct tee_context *ctx, u32 session,
 		       struct tee_shm *device_shm, u32 *shm_size)
 {
-	u32 ret = 0;
+	int ret = 0;
 	struct tee_ioctl_invoke_arg inv_arg = {0};
 	struct tee_param param[4] = {0};
 
Signature · 1 line
2.7.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · YueHaibing

The return from the call to tee_client_invoke_func can be a negative error code however this is being assigned to an unsigned variable 'ret' hence the check is always false. Fix this by making 'ret' an int.

Detected by Coccinelle ("Unsigned expression compared with zero:
ret < 0")

Fixes c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
Quoted 21 lines
---
 drivers/tee/optee/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tee/optee/device.c +1 -2
index 5e4938b..1f22376 100644
@@ -34,7 +34,7 @@ static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
 static int get_devices(struct tee_context *ctx, u32 session,
                       struct tee_shm *device_shm, u32 *shm_size)
 {
-       u32 ret = 0;
+       int ret = 0;
        struct tee_ioctl_invoke_arg inv_arg = {0};
        struct tee_param param[4] = {0};
 
--

2.7.0