From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B59E73A48C6 for ; Tue, 12 May 2026 14:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594529; cv=none; b=uKESNwaWlhq+c350k13VkUsGI44xSWIWguMpKlR7yXG4+elK9efNyQ7PrM1Wmb15M/aoIGl/upuh3ZsC7AAzzb7KNr/MrEkG35wt/vUCt0sOAu52YYL81JJkTubZ7PgWznBmNvg1l2+DaDmQRqIkA+SzHPhbpO3LlDBuH5359DM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594529; c=relaxed/simple; bh=Bhh56K988teTnrj0Bk7lsN/kCN1bDgzAD3sE4fsjjEA=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=rke2gUFkixiXYZB1F6nSl5hlDFZeV23Gvnt5aLYzXWa1U3/SvjXlse4NPQfo8olqbVJxVLXAqx8cUBf3wIO113wulM8cAL/ZkmMZaPsy4LuuGYmuV5giCmzd1/GGZtiA7j8C+Q94zJ7MKA6BLbOaELxiBhiEZie0OOTsf/lNwmw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k5WILYpk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="k5WILYpk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A6FBC2BCB0; Tue, 12 May 2026 14:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778594529; bh=Bhh56K988teTnrj0Bk7lsN/kCN1bDgzAD3sE4fsjjEA=; h=Subject:To:Cc:From:Date:From; b=k5WILYpkLiwYSompk/NDLVv+qXiYoq8RCf/GWBmKacL5i/hjDsz+Dq6In6pqeFPQC jeDnFNSmL187F0Z5Z4t8XWUnfzJOGZGl/qC8FmQjlwg8jt+2/N9TJB3CTPz9HGnPTs v7UjDKCjvrS1EA4Ec3drwHfWvAn+1wKr2YFu9kUE= Subject: FAILED: patch "[PATCH] btrfs: fix double free in create_space_info_sub_group() error" failed to apply to 6.6-stable tree To: lgs201920130244@gmail.com,dsterba@suse.com,wqu@suse.com Cc: From: Date: Tue, 12 May 2026 15:58:35 +0200 Message-ID: <2026051235-front-pushup-165a@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x a7449edf96143f192606ec8647e3167e1ecbd728 # git commit -s git send-email --to '' --in-reply-to '2026051235-front-pushup-165a@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a7449edf96143f192606ec8647e3167e1ecbd728 Mon Sep 17 00:00:00 2001 From: Guangshuo Li Date: Wed, 1 Apr 2026 19:02:19 +0800 Subject: [PATCH] btrfs: fix double free in create_space_info_sub_group() error path When kobject_init_and_add() fails, the call chain is: create_space_info_sub_group() -> btrfs_sysfs_add_space_info_type() -> kobject_init_and_add() -> failure -> kobject_put(&sub_group->kobj) -> space_info_release() -> kfree(sub_group) Then control returns to create_space_info_sub_group(), where: btrfs_sysfs_add_space_info_type() returns error -> kfree(sub_group) Thus, sub_group is freed twice. Keep parent->sub_group[index] = NULL for the failure path, but after btrfs_sysfs_add_space_info_type() has called kobject_put(), let the kobject release callback handle the cleanup. Fixes: f92ee31e031c ("btrfs: introduce btrfs_space_info sub-group") CC: stable@vger.kernel.org # 6.18+ Reviewed-by: Qu Wenruo Signed-off-by: Guangshuo Li Signed-off-by: David Sterba diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index e017bb182c8c..8278e7998bc9 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -287,10 +287,8 @@ static int create_space_info_sub_group(struct btrfs_space_info *parent, u64 flag sub_group->subgroup_id = id; ret = btrfs_sysfs_add_space_info_type(sub_group); - if (ret) { - kfree(sub_group); + if (ret) parent->sub_group[index] = NULL; - } return ret; }