]> www.infradead.org Git - users/willy/xarray.git/commit
XArray: Prevent node leaks in xas_alloc()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 23 Sep 2024 18:33:40 +0000 (14:33 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 23 Sep 2024 18:33:40 +0000 (14:33 -0400)
commitc88414f56c37f4afa730b81291502b2484f43550
treebfec869afbf9acc18f0304549852f186b57563c1
parentf8eb5bd9a818cc5f2a1e50b22b0091830b28cc36
XArray: Prevent node leaks in xas_alloc()

In the following situation, we can leak nodes:

do {
xas_split_alloc();
xas_lock();
/* Discover that xas_split() does not need to be called */
xas_store();
xas_unlock();
} while (xas_nomem());

The xas_store() is expecting to be using a node allocated by xas_alloc(),
but will use a node allocated by xas_split_alloc() instead.  That
will cause us to leak the remaining nodes which are chained through
node->parent.  Fix this by only popping the top node off the xa_alloc
list instead of removing all the nodes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
lib/xarray.c