From d817f2c69615cf37b78f484a25b7831ebe9dbe6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Wed, 22 Jan 2020 11:43:11 +0100 Subject: [PATCH] etnaviv: drm: Don't miscalculate timeout MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current code overflows (s * 1000000000) for s >= 5 but that is e.g. used in etna_bo_cpu_prep. Signed-off-by: Guido Günther Reviewed-by: Jonathan Marek Tested-by: Marge Bot Part-of: --- src/etnaviv/drm/etnaviv_priv.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/etnaviv/drm/etnaviv_priv.h b/src/etnaviv/drm/etnaviv_priv.h index 2ab0e473ea9..8ceb6c3c431 100644 --- a/src/etnaviv/drm/etnaviv_priv.h +++ b/src/etnaviv/drm/etnaviv_priv.h @@ -204,10 +204,9 @@ struct etna_perfmon_signal static inline void get_abs_timeout(struct drm_etnaviv_timespec *tv, uint64_t ns) { struct timespec t; - uint32_t s = ns / 1000000000; clock_gettime(CLOCK_MONOTONIC, &t); - tv->tv_sec = t.tv_sec + s; - tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000); + tv->tv_sec = t.tv_sec + ns / 1000000000; + tv->tv_nsec = t.tv_nsec + ns % 1000000000; } #if HAVE_VALGRIND -- 2.30.2