Re: [PATCH v4] lib: xarray: free unused spare node in xas_create_range()
From: David Hildenbrand (Red Hat)
Date: Mon Dec 08 2025 - 06:36:59 EST
-restore:Your bool-based version reads nicer; I’m happy to follow up with a
- xas->xa_shift = shift;
- xas->xa_sibs = sibs;
- xas->xa_index = index;
- return;
-success:
- xas->xa_index = index;
- if (xas->xa_node)
- xas_set_offset(xas);
+ if (success) {
+ xas->xa_index = index;
+ if (xas->xa_node)
+ xas_set_offset(xas);
+ } else {
+ xas->xa_shift = shift;
+ xas->xa_sibs = sibs;
+ xas->xa_index = index;
+ }
+ /* Free any unused spare node from xas_nomem() */
+ xas_destroy(xas);
}
EXPORT_SYMBOL_GPL(xas_create_range);
small cleanup patch on top that switches xas_create_range() over to
that style (with a Suggested-by tag).
Yeah, feel free to send a cleanup out that removes some of these labels
(doesn't necessarily have to be what I proposed).
--
Cheers
David