# \[Xen-devel\] \[RFC 02/23\] xen/xenbus: client: Fix call of virt\_to\_mfn in xenbus\_grant\_ring

- From: David Vrabel \<hidden\>
- Date: 2015-05-19 13:51:57 
- List: linux-arm-kernel
- Page: https://ratatoskr.run/linux-arm-kernel/2015/05/4497091
- Thread: https://ratatoskr.run/linux-arm-kernel/2015/05/4493732/t.md

```text
On 14/05/15 18:00, Julien Grall wrote:
> virt_to_mfn should take a void* rather an unsigned long. While it
> doesn't really matter now, it would throw a compiler warning later when
> virt_to_mfn will enforce the type.
> 
> At the same time, avoid to compute new virtual address every time in the
> loop and directly increment the parameter as we don't use it later.

Reviewed-by: David Vrabel <redacted>

But...

> --- a/drivers/xen/xenbus/xenbus_client.c
> +++ b/drivers/xen/xenbus/xenbus_client.c
> @@ -379,16 +379,16 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
>  	int i, j;
>  
>  	for (i = 0; i < nr_pages; i++) {
> -		unsigned long addr = (unsigned long)vaddr +
> -			(PAGE_SIZE * i);
>  		err = gnttab_grant_foreign_access(dev->otherend_id,
> -						  virt_to_mfn(addr), 0);
> +						  virt_to_mfn(vaddr), 0);
>  		if (err < 0) {
>  			xenbus_dev_fatal(dev, err,
>  					 "granting access to ring page");
>  			goto fail;
>  		}
>  		grefs[i] = err;
> +
> +		vaddr = (char *)vaddr + PAGE_SIZE;

You don't need the cast here since vaddr is a void *.

David
```
