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

Re: [Xen-devel] [PATCH 1/3] xen-gnt: prevent adding duplicate gnt callbacks



On Wed, Jul 31, 2013 at 05:00:42PM +0200, Roger Pau Monne wrote:
> With the current implementation, the callback in the tail of the list
> can be added twice, because the check done in
> gnttab_request_free_callback is bogus, callback->next can be NULL if
> it is the last callback in the list. If we add the same callback twice
> we end up with an infinite loop, were callback == callback->next.
> 
> Replace this check with a proper one that iterates over the list to
> see if the callback has already been added.

Acked-by: Matt Wilson <msw@xxxxxxxxxx>

> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Cc: David Vrabel <david.vrabel@xxxxxxxxxx>
> ---
> This patch should be backported to stable trees
> ---
>  drivers/xen/grant-table.c |   13 +++++++++++--
>  1 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index 04c1b2d..d5418c1 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -729,9 +729,18 @@ void gnttab_request_free_callback(struct 
> gnttab_free_callback *callback,
>                                 void (*fn)(void *), void *arg, u16 count)
>  {
>       unsigned long flags;
> +     struct gnttab_free_callback *cb;
> +
>       spin_lock_irqsave(&gnttab_list_lock, flags);
> -     if (callback->next)
> -             goto out;
> +
> +     /* Check if the callback is already on the list */
> +     cb = gnttab_free_callback_list;
> +     while (cb) {
> +             if (cb == callback)
> +                     goto out;
> +             cb = cb->next;
> +     }
> +
>       callback->fn = fn;
>       callback->arg = arg;
>       callback->count = count;

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


 


Rackspace

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