lkml.org 
[lkml]   [2020]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][next] drm/mm/selftests: fix unsigned comparison with less than zero
Date
From: Colin Ian King <colin.king@canonical.com>

Function get_insert_time can return error values that are cast
to a u64. The checks of insert_time1 and insert_time2 check for
the errors but because they are u64 variables the check for less
than zero can never be true. Fix this by casting the value to s64
to allow of the negative error check to succeed.

Addresses-Coverity: ("Unsigned compared against 0, no effect")
Fixes: 6e60d5ded06b ("drm/mm: add ig_frag selftest")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/selftests/test-drm_mm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 3846b0f5bae3..671a152a6df2 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -1124,12 +1124,12 @@ static int igt_frag(void *ignored)

insert_time1 = get_insert_time(&mm, insert_size,
nodes + insert_size, mode);
- if (insert_time1 < 0)
+ if ((s64)insert_time1 < 0)
goto err;

insert_time2 = get_insert_time(&mm, (insert_size * 2),
nodes + insert_size * 2, mode);
- if (insert_time2 < 0)
+ if ((s64)insert_time2 < 0)
goto err;

pr_info("%s fragmented insert of %u and %u insertions took %llu and %llu nsecs\n",
--
2.27.0.rc0
\
 
 \ /
  Last update: 2020-06-17 18:03    [W:0.057 / U:1.956 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site