mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
XArray: Fix xa_alloc when id exceeds max
Specifying a starting ID greater than the maximum ID isn't something
attempted very often, but it should fail. It was succeeding due to
xas_find_marked() returning the wrong error state, so add tests for
both xa_alloc() and xas_find_marked().
Fixes: b803b42823
("xarray: Add XArray iterators")
Signed-off-by: Matthew Wilcox <willy@infradead.org>
This commit is contained in:
@@ -1131,7 +1131,7 @@ void *xas_find_marked(struct xa_state *xas, unsigned long max, xa_mark_t mark)
|
||||
entry = xa_head(xas->xa);
|
||||
xas->xa_node = NULL;
|
||||
if (xas->xa_index > max_index(entry))
|
||||
goto bounds;
|
||||
goto out;
|
||||
if (!xa_is_node(entry)) {
|
||||
if (xa_marked(xas->xa, mark))
|
||||
return entry;
|
||||
@@ -1180,11 +1180,9 @@ void *xas_find_marked(struct xa_state *xas, unsigned long max, xa_mark_t mark)
|
||||
}
|
||||
|
||||
out:
|
||||
if (!max)
|
||||
if (xas->xa_index > max)
|
||||
goto max;
|
||||
bounds:
|
||||
xas->xa_node = XAS_BOUNDS;
|
||||
return NULL;
|
||||
return set_bounds(xas);
|
||||
max:
|
||||
xas->xa_node = XAS_RESTART;
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user