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 4C96A4AE12C for ; Mon, 5 Oct 2026 14:43:57 +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=1791211443; cv=none; b=LYzV1OA7id/593a4LYKP0AlVBr9XV8Nsg+8GSTd9kCB/WkUtQXdUhagm7WeqVJLKRNVhWxDtTGI6Jgojn9qUyEj/khc0eyXB6Vymnxaeafcjc1rQ2GnzORG2ieazCYbXU8wAEbXsv4vXuwQqo3U9D1B+9S40Bhg98vQUcSz1g3c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791211443; c=relaxed/simple; bh=l/iXqLdpN8sw6NEpTIzdZeIpMMZRe8c4wD2v5WJMj78=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=MzwwVeEYi083AclwVpoS/x41dKkjO1GQPRsVMZWkYA/iW36ySe/UjnwT5qE321anV6e8mRczwV5eQDOw1CUMHaly6tcr6nwRaydBqotkyT81Q/mSWKdQiCeI/9lm/Xy6NRL+jz1bkJsZsfOk/gewwBkNC6RQjUxQo6+WVDN7ZyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r+BQoMjM; 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="r+BQoMjM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0DA31F00893; Mon, 5 Oct 2026 14:43:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791211435; bh=T5gmb2vVudWOOHH9dMrI9weDEyQkXK2h8/U0bliz/8g=; h=Subject:To:Cc:From:Date; b=r+BQoMjM74g1xI+PzXqdr0d9mACslg1IWL0HwwMZ0JVfMobEQIJrSU+RibErktRNw GfWZhn7My+E+1yY7/rE83PLEcU1a0MSTfQMs+o9EWbA1Co6cHCWLLYdg+nToEEsm8g om7EFHsE0EajZdkj/9uizGhnkfKT1iMO1w9JrSuo= Subject: FAILED: patch "[PATCH] thunderbolt: Fix NULL dereference in tb_remove_work()" failed to apply to 6.12-stable tree To: pchelkin@ispras.ru,mika.westerberg@linux.intel.com Cc: From: Date: Mon, 05 Oct 2026 16:43:42 +0200 Message-ID: <2026100542-carving-container-a8df@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.12-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.12.y git checkout FETCH_HEAD git cherry-pick -x 4310c6b8e75d6a47f7548e5948fbe6318aa4440a # git commit -s git send-email --to '' --in-reply-to '2026100542-carving-container-a8df@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4310c6b8e75d6a47f7548e5948fbe6318aa4440a Mon Sep 17 00:00:00 2001 From: Fedor Pchelkin Date: Mon, 31 Aug 2026 10:58:09 +0300 Subject: [PATCH] thunderbolt: Fix NULL dereference in tb_remove_work() There is a slight race between tb_remove_work() and tb_domain_remove() which leads to dereferencing a NULL tb->root_switch pointer inside tb_free_unplugged_xdomains(): Thread A Thread B tb_remove_work() tb_domain_remove() mutex_lock(&tb->lock) tb_stop() /* doesn't cancel a running callback */ cancel_delayed_work(&tcm->remove_work) ... tb_switch_remove(tb->root_switch) tb->root_switch = NULL mutex_unlock(&tb->lock) mutex_lock(&tb->lock) ... /* without checking ->root_switch */ tb_free_unplugged_xdomains(tb->root_switch) mutex_unlock(&tb->lock) Commit a8937f35cf39 ("thunderbolt: Remove XDomain from the bus without holding tb->lock") doesn't seem right to move tb_free_unplugged_xdomains() out of the &tb->lock section and the check for tb->root_switch, in particular. It states: For this reason separate removing the XDomain from the topology data structures (where we need the lock) from unregistering the device from the bus (where remove callbacks of the drivers are being called). tb_free_unplugged_xdomains() belongs to the former group of functions requiring the lock. And it also calls tb_xdomain_remove() which should only be called with &tb->lock held. Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool. Fixes: a8937f35cf39 ("thunderbolt: Remove XDomain from the bus without holding tb->lock") Cc: stable@vger.kernel.org Signed-off-by: Fedor Pchelkin Signed-off-by: Mika Westerberg diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index ba63610d2ce2..4e5d0578fd4b 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -3285,11 +3285,11 @@ static void tb_remove_work(struct work_struct *work) struct tb *tb = tcm_to_tb(tcm); mutex_lock(&tb->lock); - if (tb->root_switch) + if (tb->root_switch) { tb_free_unplugged_children(tb->root_switch); + tb_free_unplugged_xdomains(tb->root_switch); + } mutex_unlock(&tb->lock); - - tb_free_unplugged_xdomains(tb->root_switch); } static int tb_runtime_resume(struct tb *tb)