[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] xen: fail gnttab_grow_table() in case of missing allocations

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 <jgross@xxxxxxxx>

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

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



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.