Skip to content

Commit ce6b8cc

Browse files
committed
xen/xenbus: fix xenbus_setup_ring()
Commit 4573240 ("xen/xenbus: eliminate xenbus_grant_ring()") introduced an error for initialization of multi-page rings. Cc: [email protected] Fixes: 4573240 ("xen/xenbus: eliminate xenbus_grant_ring()") Reported-by: Sander Eikelenboom <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Jan Beulich <[email protected]> Reviewed-by: Oleksandr Tyshchenko <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent e9ea0b3 commit ce6b8cc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/xen/xenbus/xenbus_client.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,10 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
382382
unsigned long ring_size = nr_pages * XEN_PAGE_SIZE;
383383
grant_ref_t gref_head;
384384
unsigned int i;
385+
void *addr;
385386
int ret;
386387

387-
*vaddr = alloc_pages_exact(ring_size, gfp | __GFP_ZERO);
388+
addr = *vaddr = alloc_pages_exact(ring_size, gfp | __GFP_ZERO);
388389
if (!*vaddr) {
389390
ret = -ENOMEM;
390391
goto err;
@@ -401,13 +402,15 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr,
401402
unsigned long gfn;
402403

403404
if (is_vmalloc_addr(*vaddr))
404-
gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr[i]));
405+
gfn = pfn_to_gfn(vmalloc_to_pfn(addr));
405406
else
406-
gfn = virt_to_gfn(vaddr[i]);
407+
gfn = virt_to_gfn(addr);
407408

408409
grefs[i] = gnttab_claim_grant_reference(&gref_head);
409410
gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id,
410411
gfn, 0);
412+
413+
addr += XEN_PAGE_SIZE;
411414
}
412415

413416
return 0;

0 commit comments

Comments
 (0)