On Fri, Sep 29, 2017 at 10:51:40AM +0000, Juergen Gross wrote:
> In case gnttab_grow_table() is being called without
> grant_table_set_limits() having been called for the domain, e.g. in
> case of a toolstack error, fail the function instead of crashing the
> system.
> 
> While at it let gnttab_grow_table() return a proper error code instead
> of 1 for success.
> 
> Signed-off-by: Juergen Gross <jgr...@suse.com>

Reviewed-by: Roger Pau Monné <roger....@citrix.com>

Just some rants below.

> @@ -1769,8 +1773,10 @@ grant_table_init(struct domain *d, struct grant_table 
> *gt)
>          goto out;
>  
>      /* gnttab_grow_table() allocates a min number of frames, so 0 is okay. */
> -    if ( gnttab_grow_table(d, 0) )
> -        goto unlock;
> +    ret = gnttab_grow_table(d, 0);
> +    if (ret)
> +        goto out;
> +    goto unlock;

I find the above chunk ugly, I usually prefer to avoid using gotos
except for if error branches. In any case, this is fine given the
current flow, and it's not so different from the original.

Also IMHO 'out' should be named 'error' instead, and it should have
an ASSERT(rc); at the beginning.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to