• Matthew Wilcox's avatar
    XArray: Fix xa_for_each with a single element at 0 · 8229706e
    Matthew Wilcox authored
    The following sequence of calls would result in an infinite loop in
    xa_find_after():
    
    	xa_store(xa, 0, x, GFP_KERNEL);
    	index = 0;
    	xa_for_each(xa, entry, index, ULONG_MAX, XA_PRESENT) { }
    
    xa_find_after() was confusing the situation where we found no entry in
    the tree with finding a multiorder entry, so it would look for the
    successor entry forever.  Just check for this case explicitly.  Includes
    a few new checks in the test suite to be sure this doesn't reappear.
    Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
    8229706e
xarray.c 52 KB