6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Darrick J. Wong commit 4ce244b234c251963fca6dff9de6edf26a209d08 upstream. LOLLM notices that both callers of xchk_btree_get_block will return early if *pblock is NULL after a successful return. However, xchk_btree_get_block itself can return 0 after flagging a corruption. There's no point in continuing after we've found a corruption, so null the pointer out. Cc: stable@vger.kernel.org # v4.15 Fixes: cc3e0948d2686f ("xfs: scrub the shape of a metadata btree") Signed-off-by: Darrick J. Wong Assisted-by: LOLLM # finding obvious bugs Reviewed-by: Christoph Hellwig Signed-off-by: Carlos Maiolino Signed-off-by: Greg Kroah-Hartman --- fs/xfs/scrub/btree.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/xfs/scrub/btree.c +++ b/fs/xfs/scrub/btree.c @@ -608,6 +608,14 @@ xchk_btree_get_block( xfs_btree_get_block(bs->cur, level, pbp); if (__xfs_btree_check_block(bs->cur, *pblock, level, *pbp)) { xchk_btree_set_corrupt(bs->sc, bs->cur, level); + /* + * The btree block fails basic checks, so we know it's corrupt. + * There's no need to continue looking for corruptions, so we + * null out pblock. If *pbp is non-null then it's also + * attached to the transaction so we won't leak it despite the + * 0 return code. + */ + *pblock = NULL; return 0; } if (*pbp)