btrfs: send: handle unexpected inode in header process_recorded_refs()
authorDavid Sterba <dsterba@suse.com>
Tue, 6 Feb 2024 21:47:13 +0000 (22:47 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:51 +0000 (16:24 +0100)
Change BUG_ON to proper error handling when an unexpected inode number
is encountered. As the comment says this should never happen.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/send.c

index 8c3ca4a5d923b061d4bf6c512a7685b3edbc3afd..3b3f38a76b005cfeef294149ff9c872d842ae3c3 100644 (file)
@@ -4186,7 +4186,13 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
         * This should never happen as the root dir always has the same ref
         * which is always '..'
         */
-       BUG_ON(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID);
+       if (unlikely(sctx->cur_ino <= BTRFS_FIRST_FREE_OBJECTID)) {
+               btrfs_err(fs_info,
+                         "send: unexpected inode %llu in process_recorded_refs()",
+                         sctx->cur_ino);
+               ret = -EINVAL;
+               goto out;
+       }
 
        valid_path = fs_path_alloc();
        if (!valid_path) {