From db89c572095cec39b54b16d980560715a60c56c8 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Wed, 2 Sep 2020 19:15:01 +0200 Subject: [PATCH] amd/common: Fix various non-critical integer overflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The result of 0xf << 28 is a signed integer and hence overflows into the sign bit. In practice compilers did the right thing here, since the intent of the code was unsigned arithmetic anyway. Cc: mesa-stable Reviewed-by: Daniel Schürmann Part-of: (cherry picked from commit 93c8777ace8453f4cbc879d0829e582cf151066f) --- .pick_status.json | 2 +- src/amd/common/ac_shader_util.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7becc542c01..a35d3ce18a3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2794,7 +2794,7 @@ "description": "amd/common: Fix various non-critical integer overflows", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/amd/common/ac_shader_util.c b/src/amd/common/ac_shader_util.c index 030c07c49ef..0a060565627 100644 --- a/src/amd/common/ac_shader_util.c +++ b/src/amd/common/ac_shader_util.c @@ -64,7 +64,7 @@ ac_get_cb_shader_mask(unsigned spi_shader_col_format) cb_shader_mask |= 0x3 << (i * 4); break; case V_028714_SPI_SHADER_32_AR: - cb_shader_mask |= 0x9 << (i * 4); + cb_shader_mask |= 0x9u << (i * 4); break; case V_028714_SPI_SHADER_FP16_ABGR: case V_028714_SPI_SHADER_UNORM16_ABGR: @@ -72,7 +72,7 @@ ac_get_cb_shader_mask(unsigned spi_shader_col_format) case V_028714_SPI_SHADER_UINT16_ABGR: case V_028714_SPI_SHADER_SINT16_ABGR: case V_028714_SPI_SHADER_32_ABGR: - cb_shader_mask |= 0xf << (i * 4); + cb_shader_mask |= 0xfu << (i * 4); break; default: assert(0);