lkml.org 
[lkml]   [2020]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] xen/xenbus: avoid large structs and arrays on the stack
From
Date
On 5/11/20 3:31 AM, Juergen Gross wrote:
>
> static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,


I wonder whether we can drop valloc/vfree from xenbus_ring_ops' names.


> + struct map_ring_valloc *info,
> grant_ref_t *gnt_ref,
> unsigned int nr_grefs,
> void **vaddr)
> {
> - struct xenbus_map_node *node;
> + struct xenbus_map_node *node = info->node;
> int err;
> void *addr;
> bool leaked = false;
> - struct map_ring_valloc_hvm info = {
> - .idx = 0,
> - };
> unsigned int nr_pages = XENBUS_PAGES(nr_grefs);
>
> - if (nr_grefs > XENBUS_MAX_RING_GRANTS)
> - return -EINVAL;
> -
> - *vaddr = NULL;
> -
> - node = kzalloc(sizeof(*node), GFP_KERNEL);
> - if (!node)
> - return -ENOMEM;
> -
> err = alloc_xenballooned_pages(nr_pages, node->hvm.pages);
> if (err)
> goto out_err;
>
> gnttab_foreach_grant(node->hvm.pages, nr_grefs,
> xenbus_map_ring_setup_grant_hvm,
> - &info);
> + info);
>
> err = __xenbus_map_ring(dev, gnt_ref, nr_grefs, node->handles,
> - info.phys_addrs, GNTMAP_host_map, &leaked);
> + info, GNTMAP_host_map, &leaked);
> node->nr_handles = nr_grefs;
>
> if (err)
> @@ -641,11 +654,13 @@ static int xenbus_map_ring_valloc_hvm(struct xenbus_device *dev,
> spin_unlock(&xenbus_valloc_lock);
>
> *vaddr = addr;
> + info->node = NULL;


Is this so that xenbus_map_ring_valloc() doesn't free it accidentally?


-boris


> +
> return 0;
>
>

[unhandled content-type:application/pgp-keys]
\
 
 \ /
  Last update: 2020-05-11 20:02    [W:0.173 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site