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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Mukul Joshi <mukul.joshi@xxxxxxx>
---
 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

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux