diff mbox

[11/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap()

Message ID 20180126182911.20761-12-tom.stdenis@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

StDenis, Tom Jan. 26, 2018, 6:29 p.m. UTC
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Felix Kuehling Jan. 26, 2018, 7:20 p.m. UTC | #1
On 2018-01-26 01:29 PM, Tom St Denis wrote:
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
> ---
>  drivers/gpu/drm/ttm/ttm_bo_vm.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 07b22f04b969..6311f8a481ea 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -345,6 +345,7 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
>  		page++;
>  		bytes_left -= bytes;
>  		offset = 0;
> +		buf += bytes;

I'd put this right before the bytes_left -= bytes.

Also, buf is a void *. That makes pointer arithmetic on it somewhat
undefined. From what I can find, GCC supports it as an extension. See
also
https://stackoverflow.com/questions/3523145/pointer-arithmetic-for-void-pointer-in-c.

If it compiles without a warning, I guess it's OK as is.

Regards,
  Felix

>  	} while (bytes_left);
>  
>  	return len;
diff mbox

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 07b22f04b969..6311f8a481ea 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -345,6 +345,7 @@  static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
 		page++;
 		bytes_left -= bytes;
 		offset = 0;
+		buf += bytes;
 	} while (bytes_left);
 
 	return len;