[PATCH v2] drm/amdkfd: Fix the shift-out-of-bounds warning

Ma Jun Jun.Ma2 at amd.com
Thu Jan 11 09:44:26 UTC 2024


There is shift-out-of-bounds warning following if ecode=0.
"shift exponent 4294967295 is too large for 64-bit type 'long long unsigned int'"

Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
Suggested-by: Felix Kuehling <felix.kuehling at amd.com>
---
 include/uapi/linux/kfd_ioctl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 2aa88afe305b..90b04c0401fc 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -1004,7 +1004,7 @@ enum kfd_dbg_trap_exception_code {
 };
 
 /* Mask generated by ecode in kfd_dbg_trap_exception_code */
-#define KFD_EC_MASK(ecode)	(1ULL << (ecode - 1))
+#define KFD_EC_MASK(ecode)	((ecode) ? 1ULL << (ecode - 1) : 0ULL)
 
 /* Masks for exception code type checks below */
 #define KFD_EC_MASK_QUEUE	(KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) |	\
-- 
2.34.1



More information about the amd-gfx mailing list