From 7d14a0cb999bf2b3fd880516b12e91c3ef271744 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 19 Apr 2021 17:54:11 +0200 Subject: [PATCH] panfrost: Make sure pack_work_groups_compute() is passed valid dimensions Make sure size_{x,y,z} and num_{x,y,s} are positive, otherwise we end up with an integer underflow. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_invocation.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/panfrost/lib/pan_invocation.c b/src/panfrost/lib/pan_invocation.c index 4c0f6457851..c92296fc37e 100644 --- a/src/panfrost/lib/pan_invocation.c +++ b/src/panfrost/lib/pan_invocation.c @@ -57,6 +57,12 @@ panfrost_pack_work_groups_compute( unsigned shifts[7] = { 0 }; + /* Make sure size_{x,y,z} and num_{x,y,z} are positive, otherwise we + * end up with an integer underflow. + */ + assert(size_x && size_y && size_z); + assert(num_x && num_y && num_z); + unsigned values[6] = { MALI_POSITIVE(size_x), MALI_POSITIVE(size_y),