signal_eviction_fence() is declared to return bool, but returns -EINVAL
when no eviction fence is present.  This makes the "no fence" path
evaluate to true and triggers a Smatch warning.

Return false when the fence pointer is NULL, and keep propagating the
result of dma_fence_check_and_signal().

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:2099 signal_eviction_fence()
warn: '(-22)' is not bool

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c
    2090 static bool signal_eviction_fence(struct kfd_process *p)
                ^^^^

    2091 {
    2092         struct dma_fence *ef;
    2093         bool ret;
    2094
    2095         rcu_read_lock();
    2096         ef = dma_fence_get_rcu_safe(&p->ef);
    2097         rcu_read_unlock();
    2098         if (!ef)
--> 2099                 return -EINVAL;

This should be either true or false.  Probably true because presumably it has 
been tested?

    2100
    2101         ret = dma_fence_check_and_signal(ef);
    2102         dma_fence_put(ef);
    2103
    2104         return ret;
    2105 }

Fixes: 37865e02e6cc ("drm/amdkfd: Fix eviction fence handling")
Reported by: Dan Carpenter <[email protected]>
Cc: Philip Yang <[email protected]>
Cc: Gang BA <[email protected]>
Cc: Felix Kuehling <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 2a72dc95cc0f..3e7e91dd4316 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -2097,7 +2097,7 @@ static int signal_eviction_fence(struct kfd_process *p)
        ef = dma_fence_get_rcu_safe(&p->ef);
        rcu_read_unlock();
        if (!ef)
-               return -EINVAL;
+               return false;
 
        ret = dma_fence_signal(ef);
        dma_fence_put(ef);
-- 
2.34.1

Reply via email to