Re: [PATCH] btrfs: Add missing sctx check in cleanup path
From: David Sterba
Date: Mon Jul 13 2026 - 14:35:31 EST
On Tue, Jul 07, 2026 at 05:16:04PM +0800, Hongling Zeng wrote:
> Add sctx NULL check in the sort_clone_roots cleanup path for
> consistency with other cleanup paths in the function.
>
> Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
> ---
> fs/btrfs/send.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 3ae480c7474b..2d81fac03a3d 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -8250,7 +8250,7 @@ long btrfs_ioctl_send(struct btrfs_root *send_root, const struct btrfs_ioctl_sen
> free_orphan_dir_info(sctx, odi);
> }
>
> - if (sort_clone_roots) {
> + if (sctx && sort_clone_roots) {
The check for sctx is indeed missing but in the else branch the
condition is inside the for loop:
for (i = 0; sctx && i < clone_sources_to_rollback; i++) {
It would be better to place it there for consistency.
Overall in the function many of the sctx checks can be removed if the
allocation is moved to the beginning.