From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2C8DF3B994F; Wed, 30 Sep 2026 19:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790795083; cv=none; b=X9urBk3jDYy8nvBvHQB/wtBvOI0oMfQKPLmv+P44zj7i0yWu+PI6f73ICAwjHwz90kXrK6yXitngJklnz9GnbqnafVfGHw+ieT0zqtG2lyEYto2iKMgcz/duwprVYjIT3XHhpxjQy+EO/egTjZNOFd6XIHT0VA9Pg1JdaZzwL64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790795083; c=relaxed/simple; bh=BRO75oWvT/sd9E4p+zcqV53DLITZk8MAD3zSeN2Oz74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LaQ/9GohSgKPEdylkkFAwCZ+rLtDZ62TlGjJSYMTAhBbrvbYp4feh10umFXYIKD/sSutEDZbvzNmzrRphykSTDeWh2eE3RLdRhXPWbhstijSFxzk43sdY6yNRZc3CS33zNJqoazDFFca88h3M8qOXxc3o038wKDlmI1SnerMu3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ef2YRppo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ef2YRppo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DB6F1F0092C; Wed, 30 Sep 2026 19:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790795079; bh=0/DANg+1PsFFnRqL3mSKKlVnlX3iY8OGXsMiiIjKaBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ef2YRppoGpc7ivkJogdtm6pnk1aAAtiSPHsPfr21FugU6KvneKTYJ7k1FbGZbDpwx /a/xsdlRpp2ZHR7Y5yh7zuy86n6llyLY0+zx166ppoqg3uH+yqscLiLNGhS9JicfkW WFdbTmsB7i1Pi5mg/zqciL2B2owml4h8BjAtzgfQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qu Wenruo , Guanghui Yang <3497809730@qq.com>, David Sterba , Sasha Levin Subject: [PATCH 6.6 0437/1193] btrfs: detach failed sprout device from transaction update list Date: Wed, 30 Sep 2026 17:18:41 +0200 Message-ID: <20260930152443.896408715@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152434.301151190@linuxfoundation.org> References: <20260930152434.301151190@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guanghui Yang <3497809730@qq.com> [ Upstream commit c93b3c43df561cd9f592cee20ae058b563f9e5b6 ] When creating the first metadata chunk for a sprout filesystem, create_chunk() adds the new device to the transaction dev_update_list through device->post_commit_list. If the subsequent system chunk creation fails, btrfs_init_new_device() aborts the transaction and releases the device while post_commit_list is still linked. This triggers a warning in btrfs_free_device() and leaves the transaction list referencing freed memory. Detach the device while holding chunk_mutex before releasing it. Fixes: bbbf7243d62d ("btrfs: combine device update operations during transaction commit") Assisted-by: Codex:gpt-5 Reviewed-by: Qu Wenruo Signed-off-by: Guanghui Yang <3497809730@qq.com> Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b72fc74f6298c..44abd64ffd3aa 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2865,6 +2865,8 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path btrfs_sysfs_remove_device(device); mutex_lock(&fs_info->fs_devices->device_list_mutex); mutex_lock(&fs_info->chunk_mutex); + if (!list_empty(&device->post_commit_list)) + list_del_init(&device->post_commit_list); list_del_rcu(&device->dev_list); list_del(&device->dev_alloc_list); fs_info->fs_devices->num_devices--; -- 2.53.0