lkml.org 
[lkml]   [2013]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 06/93] xen-gnt: prevent adding duplicate gnt callbacks
    Date
    3.8.13.10 -stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Roger Pau Monne <roger.pau@citrix.com>

    commit 5f338d9001094a56cf87bd8a280b4e7ff953bb59 upstream.

    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.

    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Cc: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Acked-by: Matt Wilson <msw@amazon.com>
    Reviewed-by: David Vrabel <david.vrabel@citrix.com>
    Signed-off-by: Kamal Mostafa <kamal@canonical.com>
    ---
    drivers/xen/grant-table.c | 13 +++++++++++--
    1 file changed, 11 insertions(+), 2 deletions(-)

    diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
    index 157c0cc..51be226 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;
    --
    1.8.1.2
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2013-09-20 23:21    [W:4.731 / U:0.624 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site