linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drm/amdkfd: fix uint32 variable compared to less than zero
@ 2021-04-22 12:31 Colin King
  2021-04-22 19:42 ` Felix Kuehling
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-04-22 12:31 UTC (permalink / raw)
  To: Felix Kuehling, Alex Deucher, Christian König, David Airlie,
	Daniel Vetter, Alex Sierra, Philip Yang, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 0e0b4ffd20ab..bf3c8de85b4a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -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;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] drm/amdkfd: fix uint32 variable compared to less than zero
  2021-04-22 12:31 [PATCH][next] drm/amdkfd: fix uint32 variable compared to less than zero Colin King
@ 2021-04-22 19:42 ` Felix Kuehling
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Kuehling @ 2021-04-22 19:42 UTC (permalink / raw)
  To: Colin King, Alex Deucher, Christian König, David Airlie,
	Daniel Vetter, Alex Sierra, Philip Yang, amd-gfx, dri-devel
  Cc: kernel-janitors, linux-kernel

Am 2021-04-22 um 8:31 a.m. schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied to amd-staging-drm-next.

Thanks,
  Felix


> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 0e0b4ffd20ab..bf3c8de85b4a 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-22 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 12:31 [PATCH][next] drm/amdkfd: fix uint32 variable compared to less than zero Colin King
2021-04-22 19:42 ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).