Re: [syzbot] Re: [syzbot] [btrfs?] memory leak in btrfs_ref_tree_mod

From: syzbot
Date: Sun Nov 12 2023 - 04:40:35 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [btrfs?] memory leak in btrfs_ref_tree_mod
Author: bragathemanick0908@xxxxxxxxx


On 12/11/23 14:53, syzbot wrote:
> Hello,
>
> syzbot tried to test the proposed patch but the build/boot failed:
>
> failed to apply patch:
> checking file fs/btrfs/ref-verify.c
> Hunk #1 FAILED at 791.
> Hunk #2 FAILED at 800.
> 2 out of 2 hunks FAILED
>
>
>
> Tested on:
>
> commit: 1b907d05 Merge tag '6.7-rc-smb3-client-fixes-part2' of..
> git tree: upstream
> kernel config: https://syzkaller.appspot.com/x/.config?x=2bf8962e4f7984f4
> dashboard link: https://syzkaller.appspot.com/bug?extid=d66de4cbf532749df35f
> compiler:
> patch: https://syzkaller.appspot.com/x/patch.diff?x=16845fe0e80000
>
#syz test

--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -791,6 +791,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
             dump_ref_action(fs_info, ra);
             kfree(ref);
             kfree(ra);
+            kfree(re);
             goto out_unlock;
         } else if (be->num_refs == 0) {
             btrfs_err(fs_info,
@@ -800,6 +801,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
             dump_ref_action(fs_info, ra);
             kfree(ref);
             kfree(ra);
+            kfree(re);
             goto out_unlock;
         }

@@ -822,6 +824,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
                 dump_ref_action(fs_info, ra);
                 kfree(ref);
                 kfree(ra);
+                kfree(re);
                 goto out_unlock;
             }
             exist->num_refs--;
@@ -838,6 +841,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
             dump_ref_action(fs_info, ra);
             kfree(ref);
             kfree(ra);
+            kfree(re);
             goto out_unlock;
         }
         kfree(ref);
@@ -849,6 +853,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
             dump_ref_action(fs_info, ra);
             kfree(ref);
             kfree(ra);
+            kfree(re);
             goto out_unlock;
         }
     }
@@ -881,6 +886,8 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
     }
     list_add_tail(&ra->list, &be->actions);
     ret = 0;
+    kfree(ra);
+    kfree(re);
 out_unlock:
     spin_unlock(&fs_info->ref_verify_lock);
 out: