From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385514; b=SlYmWJi+fsYrI/o0xjHng5F9hrDTcHNvL5pPpYMjOHPMQ/+OHJUVo/I/nI6A6SAF3FJ/ OPk2q6JLb0hX7MfXUU6AGwQWcvcUUo6dfK++AQsOjuDglhgJbyU7EJC+di+cCLTj2JdQs SZB866Y7rXTyycrFtmf/9SveM3KKigfcmx3PLpr1bzT/rsFqSKi4YoNiJbT5JOz8WwuJr nbyad0mbCK+yewM8pJ9wgg/yaVVF4qS1vSUWpDSD7eCYWgfrI0z7F14s4eWMYrF1UvBiY k5r/eCT8qOTNMhzsWnxLYDoMeL9FrubazDLs8+du5SNPTguX2qMiTLSPjShOqebjKRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385514; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=sfEb+g/lZ4NBfLylZlttZQPb9h3s/CWpWlwXjPDvd/g=; b=Uke+ku0oQekYpmd4hC2V+CSLbXCAFbGYsFDLzAD8hbNTDJLVWnJOq+z5NuqZcbmTpfMk xQNS00ry42ordIuURiFeAZ85jQa3g/tRo+RxcrE2/rqJWJtwMUWkehGSnKboV4NgZsqyo IUp5NTriEtDt+kw0WuPt/fXvIaa39WEXP0UIa33f7xf4mQkVokE0XRCQSDv5DHbcDhmlZ uo88X056hvdeFwxw62WJmBhafloa/RMF0poojAGU3N5CUJR9gCysn9chVCx+82+pnstQB pwzBTY1r7CZl752UcFCyARsVMyIq5fKmVRP9xKjaZZ4vWgLrWFTuMFlgAnJU65LYkKA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=L4u2SbSv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20C4F606A68D; Fri, 4 Dec 2026 11:58:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=L4u2SbSv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 842F91F00A2A; Fri, 4 Dec 2026 11:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385514; bh=sfEb+g/lZ4NBfLylZlttZQPb9h3s/CWpWlwXjPDvd/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L4u2SbSv/MoxhXfo/2TS7vZGD87ktKTRVTL9S6QeA5EKvvgjVuZRkNyu1ylpz37xf 50uxX1m2FVJ5vltoUNKCfykA9Ms85F057ZMYhvXrjY6NnfKFzezHCflZ0OLvBFof1y b0hgwJYM/efE10w5axnKrRX1rpbyz0KDxyZlo7gA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Balasubramani Vivekanandan , Bartosz Golaszewski , Heikki Krogerus , Johan Hovold Subject: [PATCH 6.6 0546/1167] software node: only let the owner release a managed node Date: Fri, 4 Dec 2026 18:59:33 +0900 Message-ID: <20261204100716.277560560@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski commit f8623ce596492d2e96ca57eeec992938d3d79f00 upstream. device_create_managed_software_node() creates a node whose lifetime is tied to the device it was created for. software_node_notify_remove() is called for every device that has the node as its fwnode (primary OR secondary) and, if the node is managed, unconditionally detaches it from that device and drops the creation reference. This breaks when the node is shared with another device. Example: the i2c-designware copies the parent's fwnode to the adapter's struct device. When the adapter is deleted, it releases the reference that belongs to the owner and the latter ends up with a dangling pointer. Record the device's "manager" and only perform the actual release when notify is called for that "owner" device. Note that it was never the intention that managed software nodes would be shared, but descendants reusing ancestor firmware nodes is not uncommon and such use is hard to predict when allocating software nodes. Reported-by: Balasubramani Vivekanandan Closes: https://lore.kernel.org/all/20261009164241.923756-2-balasubramani.vivekanandan@intel.com/ Fixes: 151f6ff78cdf ("software node: Provide replacement for device_add_properties()") Signed-off-by: Bartosz Golaszewski Fixes: 0f485f88656a ("drm/xe/i2c: use device_create_managed_software_node()") Reviewed-by: Balasubramani Vivekanandan Tested-by: Balasubramani Vivekanandan Reviewed-by: Heikki Krogerus Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261102-swnode-only-owner-release-v1-1-ee4c9022a629@oss.qualcomm.com [ johan: drop temporary variable; skip clearing owner field; mention reuse not intended in commit message ] Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/base/swnode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -18,6 +18,8 @@ struct swnode { struct fwnode_handle fwnode; const struct software_node *node; int id; + /* Device the managed node's lifetime is tied to. */ + struct device *owner; /* hierarchy */ struct ida child_ids; @@ -26,7 +28,6 @@ struct swnode { struct swnode *parent; unsigned int allocated:1; - unsigned int managed:1; }; static DEFINE_IDA(swnode_root_ids); @@ -1049,7 +1050,7 @@ int device_create_managed_software_node( if (IS_ERR(fwnode)) return PTR_ERR(fwnode); - to_swnode(fwnode)->managed = true; + to_swnode(fwnode)->owner = dev; set_secondary_fwnode(dev, fwnode); if (device_is_registered(dev)) @@ -1093,7 +1094,7 @@ void software_node_notify_remove(struct sysfs_remove_link(&dev->kobj, "software_node"); kobject_put(&swnode->kobj); - if (swnode->managed) { + if (swnode->owner == dev) { set_secondary_fwnode(dev, NULL); kobject_put(&swnode->kobj); }