From nobody Sat Feb 7 13:06:35 2026 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4341133E7 for ; Fri, 12 Dec 2025 00:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765499436; cv=none; b=SnYvTopJE2I+7I64EfdnZq8MvfaNCzSThdOM2aF7Tb0EOzqM7WoN1Teq5QC7HQDI+TcLfTMBAhp1QoFksD9dCuQ3MPNMT2B+nupCXA102cr5UKy2AAtPwrXF9Qs42f2NES6mwD9qE5eM8P81DIkJsrwXoeVOe7hO/1FYqMUX5Ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765499436; c=relaxed/simple; bh=imYoXBDLSOHaMpbFj2lO/URjhD3gftRaB9Zk6BSZoic=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=D9e55iaBnOFZ+xFwC6LZTEZrajj9b9xXx60wjFSeOJ+flEFokvjP8ZPdGgtvA+wU2vrYB5tV8jOayajn2X2ppel6oHHnNMh2eSJvJCOFb8q6iUSfsQfqQxtwpp46tsaOF0X4wg3doZ/pmujnEjwbDbOB7SPX2g51E0gB4FhjMQk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-656bc3a7ab3so1054495eaf.2 for ; Thu, 11 Dec 2025 16:30:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765499434; x=1766104234; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QUlrFSI3/NglDjMcvQheVY9i9PXOix/R+sBfhNrLj14=; b=vgGVJqfsxbBBMEgL0nxWW0K+Nd0Uz8aBIpLeqSqFCTtwa2yaUxbntsY+oCovQwryqk br93pM881p2uMfwbVSC73cfLVVUtvbG9Dd4cIeT/Efwf8Fv6Lp+QwJ8SgQxw+SFIg/kc SA0kNfRXHPxxYXmFXvGFalzLa6tfUg/hg/7Aj5LYsAgIPreT6nwifWVhymgVSF+7R9Pc RBwVF9PhJdpbX52V8dBOhmR7DEeyNmL9aIe7y/AwyNUdJ3cABuGUMD7IDaI/GseeEbWZ mX4Cxdf/FL28zVdFEKWkYzD+AkNwPe+cZGLYCM8FebH7to8Dp293M36eaEzEASABA3y8 diIQ== X-Gm-Message-State: AOJu0YznWHEnGDcZeXLQ6y9iey5tay3W4eptG/PbNTHJo3ZAKafDxB7n uYje2722I1PC+LBEh57EJ7ZVXQ7Pjyhw7RPNZdId6obUA3kpzvNSGcnlUJPlq0p1MFmwe5f2xqc +wtnWva6en+J/HX+tyT54FkSljgjx0vHiUlUFIjNVj31Yuj2WL9s9SMlDqlw= X-Google-Smtp-Source: AGHT+IEjcPvOa0n4ZkGCUJIrpC5jbj6Nhrh0w2gmVs5rx+SBPUcWnT2e2WGekWcg4wcne6BnCa3av+yWMS7Dr4kJ6n5MXFTDvY5T Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1891:b0:65b:33ec:1bb3 with SMTP id 006d021491bc7-65b452c8e62mr161120eaf.80.1765499434406; Thu, 11 Dec 2025 16:30:34 -0800 (PST) Date: Thu, 11 Dec 2025 16:30:34 -0800 In-Reply-To: <693b4abb.a70a0220.33cd7b.003b.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <693b622a.a70a0220.33cd7b.003d.GAE@google.com> Subject: Forwarded: [PATCH] btrfs: qgroup: fix memory leak when add_qgroup_item() fails From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] btrfs: qgroup: fix memory leak when add_qgroup_item() fails Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master If add_qgroup_item() fails, we jump to the out label without freeing the preallocated qgroup structure. This causes a memory leak and triggers the ASSERT(prealloc =3D=3D NULL) assertion. Fix this by freeing prealloc and setting it to NULL before jumping to the out label when add_qgroup_item() fails. Reported-by: syzbot+803e4cb8245b52928347@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D803e4cb8245b52928347 Fixes: 8d54518b5e52 ("btrfs: qgroup: pre-allocate btrfs_qgroup to reduce GF= P_ATOMIC usage") Signed-off-by: Deepanshu Kartikey --- fs/btrfs/qgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 9e2b53e90dcb..4dbf6d2d2aaa 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1671,8 +1671,11 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *t= rans, u64 qgroupid) } =20 ret =3D add_qgroup_item(trans, quota_root, qgroupid); - if (ret) + if (ret) { + kfree(prealloc); + prealloc =3D NULL; goto out; + } =20 spin_lock(&fs_info->qgroup_lock); qgroup =3D add_qgroup_rb(fs_info, prealloc, qgroupid); --=20 2.43.0