linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] tee: optee: Fix unsigned comparison with less than zero
@ 2019-02-19  7:04 YueHaibing
  2019-02-19  8:46 ` Sumit Garg
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2019-02-19  7:04 UTC (permalink / raw)
  To: sumit.garg, jens.wiklander; +Cc: linux-kernel, 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")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/tee/optee/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
index 5e4938b..1f22376 100644
--- a/drivers/tee/optee/device.c
+++ b/drivers/tee/optee/device.c
@@ -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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] tee: optee: Fix unsigned comparison with less than zero
  2019-02-19  7:04 [PATCH -next] tee: optee: Fix unsigned comparison with less than zero YueHaibing
@ 2019-02-19  8:46 ` Sumit Garg
  0 siblings, 0 replies; 2+ messages in thread
From: Sumit Garg @ 2019-02-19  8:46 UTC (permalink / raw)
  To: YueHaibing; +Cc: Jens Wiklander, Linux Kernel Mailing List

On Tue, 19 Feb 2019 at 12:34, YueHaibing <yuehaibing@huawei.com> wrote:
>
> 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")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>

> ---
>  drivers/tee/optee/device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
> index 5e4938b..1f22376 100644
> --- a/drivers/tee/optee/device.c
> +++ b/drivers/tee/optee/device.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-19  8:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19  7:04 [PATCH -next] tee: optee: Fix unsigned comparison with less than zero YueHaibing
2019-02-19  8:46 ` Sumit Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).