]> xenbits.xensource.com Git - people/royger/linux.git/commitdiff
xen-blkback: fix foreach_grant_safe to handle empty lists
authorRoger Pau Monne <roger.pau@citrix.com>
Fri, 8 Feb 2013 10:25:00 +0000 (11:25 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Wed, 27 Feb 2013 16:02:46 +0000 (17:02 +0100)
We may use foreach_grant_safe in the future with empty lists, so make
sure we can handle them.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: xen-devel@lists.xen.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkback/blkback.c

index d40beb39bf909e7456b698732cd5c7b406233b57..415a0c70e595cf53e27602d8571f326ca35d194c 100644 (file)
@@ -164,7 +164,7 @@ static void make_response(struct xen_blkif *blkif, u64 id,
 
 #define foreach_grant_safe(pos, n, rbtree, node) \
        for ((pos) = container_of(rb_first((rbtree)), typeof(*(pos)), node), \
-            (n) = rb_next(&(pos)->node); \
+            (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL; \
             &(pos)->node != NULL; \
             (pos) = container_of(n, typeof(*(pos)), node), \
             (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)