mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: clm@fb.com, dsterba@suse.com, wqu@suse.com, fdmanana@suse.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+803e4cb8245b52928347@syzkaller.appspotmail.com
Subject: Re: [PATCH] btrfs: qgroup: fix memory leak when add_qgroup_item() fails
Date: Fri, 12 Dec 2025 04:03:57 +0100	[thread overview]
Message-ID: <20251212030357.GO4859@twin.jikos.cz> (raw)
In-Reply-To: <20251212005224.3565337-1-kartikey406@gmail.com>

On Fri, Dec 12, 2025 at 06:22:24AM +0530, Deepanshu Kartikey wrote:
> 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 == 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=803e4cb8245b52928347
> Fixes: 8d54518b5e52 ("btrfs: qgroup: pre-allocate btrfs_qgroup to reduce GFP_ATOMIC usage")
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>

Thanks for the fix, this has been fixed in a different way by commit
https://github.com/btrfs/linux/commit/b95d1588dd2395d0fa1cd3ecf368b2dcec5445ff
and there were more problems than the one you fixed.

You're probably using master branch where this code is still broken so
the fix is present only in the development for-next branch. It's been in
linux-next.git though so you may want to check there first before
sending fixes.

  reply	other threads:[~2025-12-12  3:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12  0:52 Deepanshu Kartikey
2025-12-12  3:03 ` David Sterba [this message]
2025-12-12  3:09   ` Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251212030357.GO4859@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@suse.com \
    --cc=kartikey406@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+803e4cb8245b52928347@syzkaller.appspotmail.com \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®