From f5641c2dcb99eb006a2ad359099af05e33e26929 Mon Sep 17 00:00:00 2001 From: Kent Russell Date: Tue, 21 Nov 2017 11:51:28 -0500 Subject: [PATCH 2868/4131] drm/amdkfd: Fix logic for mem_available sizeof returns size_t (which is an unsigned int), and mem_available is signed. signed - unsigned = unsigned in C apparently. Since the result is unsigned, fix the logic and see if the sizeof(struct) is bigger than mem_available Change-Id: I672374e77a2c7bbf5260ad7ff161223777fc6265 Signed-off-by: Kent Russell --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index 5f597a6..1664ba3 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -508,7 +508,7 @@ static int fill_in_pcache(struct crat_subtype_cache *pcache, int first_active_cu; /* First check if enough memory is available */ - if (mem_available - sizeof(struct crat_subtype_cache) < 0) + if (sizeof(struct crat_subtype_cache) > mem_available) return -ENOMEM; cu_sibling_map_mask = cu_bitmask; -- 2.7.4