mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
XArray: Fix xas_pause at ULONG_MAX
If we were unlucky enough to call xas_pause() when the index was at ULONG_MAX (or a multi-slot entry which ends at ULONG_MAX), we would wrap the index back around to 0 and restart the iteration from the beginning. Use the XAS_BOUNDS state to indicate that we should just stop the iteration. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
This commit is contained in:
@@ -967,6 +967,7 @@ void xas_pause(struct xa_state *xas)
|
||||
if (xas_invalid(xas))
|
||||
return;
|
||||
|
||||
xas->xa_node = XAS_RESTART;
|
||||
if (node) {
|
||||
unsigned int offset = xas->xa_offset;
|
||||
while (++offset < XA_CHUNK_SIZE) {
|
||||
@@ -974,10 +975,11 @@ void xas_pause(struct xa_state *xas)
|
||||
break;
|
||||
}
|
||||
xas->xa_index += (offset - xas->xa_offset) << node->shift;
|
||||
if (xas->xa_index == 0)
|
||||
xas->xa_node = XAS_BOUNDS;
|
||||
} else {
|
||||
xas->xa_index++;
|
||||
}
|
||||
xas->xa_node = XAS_RESTART;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xas_pause);
|
||||
|
||||
@@ -1079,13 +1081,13 @@ void *xas_find(struct xa_state *xas, unsigned long max)
|
||||
{
|
||||
void *entry;
|
||||
|
||||
if (xas_error(xas))
|
||||
if (xas_error(xas) || xas->xa_node == XAS_BOUNDS)
|
||||
return NULL;
|
||||
|
||||
if (!xas->xa_node) {
|
||||
xas->xa_index = 1;
|
||||
return set_bounds(xas);
|
||||
} else if (xas_top(xas->xa_node)) {
|
||||
} else if (xas->xa_node == XAS_RESTART) {
|
||||
entry = xas_load(xas);
|
||||
if (entry || xas_not_node(xas->xa_node))
|
||||
return entry;
|
||||
|
Reference in New Issue
Block a user