[PATCH v2] drm/amdkfd: sparse: Fix warning in reading SDMA counters

Mukul Joshi mukul.joshi at amd.com
Mon Aug 17 23:58:12 UTC 2020


Add __user annotation to fix related sparse warning while reading
SDMA counters from userland.

Reported-by: kernel test robot <lkp at intel.com>
Signed-off-by: Mukul Joshi <mukul.joshi at amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index e0e60b0d0669..e2894967c372 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -157,19 +157,16 @@ int read_sdma_queue_counter(uint64_t q_rptr, uint64_t *val)
 {
 	int ret;
 	uint64_t tmp = 0;
+	uint64_t __user *sdma_usage_cntr;
 
 	if (!val)
 		return -EINVAL;
 	/*
 	 * SDMA activity counter is stored at queue's RPTR + 0x8 location.
 	 */
-	if (!access_ok((const void __user *)(q_rptr +
-					sizeof(uint64_t)), sizeof(uint64_t))) {
-		pr_err("Can't access sdma queue activity counter\n");
-		return -EFAULT;
-	}
+	sdma_usage_cntr = (uint64_t __user *)q_rptr + 1;
 
-	ret = get_user(tmp, (uint64_t *)(q_rptr + sizeof(uint64_t)));
+	ret = get_user(tmp, sdma_usage_cntr);
 	if (!ret) {
 		*val = tmp;
 	}
-- 
2.17.1



More information about the amd-gfx mailing list