Skip to contentSkip to conversation

drm/amdkfd: fix uint32 variable compared to less than zero

PATCH Applied Colin King 2 participants 2 messages Apr 22, 2021

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/amdkfd: fix uint32 variable compared to less than zero

From: Colin Ian King <[email protected]>

Currently the call to kfd_process_gpuidx_from_gpuid is returning an int value and this is being assigned to a uint32_t variable gpuidx and this is being checked for a negative error return which is always going to be false. Fix this by making gpuidx an int32_t. This makes gpuidx also type consistent with the use of gpuidx from the callers.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes cda0f85bfa5e ("drm/amdkfd: refine migration policy with xnack on")
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 0e0b4ffd20ab..bf3c8de85b4a 100644
@@ -1330,7 +1330,7 @@ static void svm_range_unreserve_bos(struct svm_validate_context *ctx)
  */
 static int svm_range_validate_and_map(struct mm_struct *mm,
 				      struct svm_range *prange,
-				      uint32_t gpuidx, bool intr, bool wait)
+				      int32_t gpuidx, bool intr, bool wait)
 {
 	struct svm_validate_context ctx;
 	struct hmm_range *hmm_range;
Signature · 6 lines
2.30.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Applied
#1 lore raw

Am 2021-04-22 um 8:31 a.m. schrieb Colin King:

Quoted 11 lines

From: Colin Ian King <[email protected]>

Currently the call to kfd_process_gpuidx_from_gpuid is returning an int value and this is being assigned to a uint32_t variable gpuidx and this is being checked for a negative error return which is always going to be false. Fix this by making gpuidx an int32_t. This makes gpuidx also type consistent with the use of gpuidx from the callers.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes cda0f85bfa5e ("drm/amdkfd: refine migration policy with xnack on")

Applied to amd-staging-drm-next.

Thanks,
  Felix

Quoted 17 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 0e0b4ffd20ab..bf3c8de85b4a 100644
@@ -1330,7 +1330,7 @@ static void svm_range_unreserve_bos(struct svm_validate_context *ctx)
  */
 static int svm_range_validate_and_map(struct mm_struct *mm,
 				      struct svm_range *prange,
-				      uint32_t gpuidx, bool intr, bool wait)
+				      int32_t gpuidx, bool intr, bool wait)
 {
 	struct svm_validate_context ctx;
 	struct hmm_range *hmm_range;