amdgpu_dma_buf_attach() locks bo->tbo.base.resv before updating the BO
sharing state and unlocks it before returning.

Return the local status variable after the unlock so the function has a
single consistent success return path, which avoids the Smatch warning
about inconsistent reservation lock handling.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:111 amdgpu_dma_buf_attach() warn: 
inconsistent returns 'bo->tbo.base.resv'.

Fixes: 6e6db2722c28 ("drm/amdgpu: add independent DMA-buf export v8")
Cc: Dan Carpenter <[email protected]>
Cc: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 656c267dbe58..9cf240ad5471 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -108,7 +108,7 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
 
        dma_resv_unlock(bo->tbo.base.resv);
 
-       return 0;
+       return r;
 }
 
 /**
-- 
2.34.1

Reply via email to