Re: [PATCH v3 0/8] driver core: platform: fix swnode use-after-free on device release

From: Johan Hovold

Date: Fri Nov 20 2026 - 10:33:33 EST


On Tue, Nov 17, 2026 at 11:13:28AM +0100, Johan Hovold wrote:
> When fixing a use-after-free regression in 7.3, I noticed that the
> software node implementation is internally inconsistent.
>
> Specifically, the firmware node pointer of a struct device may point to
> either a primary or secondary firmware node, but in several places
> kernel-doc and comments suggests that the firmware node pointer always
> points to a primary node (cf. [1][2]).
>
> This series fixes the 7.3 regression along with a similar issue in i2c
> core due which are both stem from the fact that
> device_remove_software_node() happens to drop a reference to a primary
> software node that was never added by device_add_software_node().
>
> The next two patches clarify that device_remove_software_node() should
> only be used to remove nodes added by device_add_software_node() and
> stops touching primary nodes.
>
> The rest of the series addresses further inconsistencies.
>
> The first two fixes could go into 7.4 and the rest (which depends on the
> fixes) into 7.5. And preferably with an ack from the i2c maintainer for
> patches 2/8 and 4/8.

> Johan Hovold (8):
> driver core: platform: fix swnode use-after-free on device release
> i2c: core: fix swnode use-after-free on client deregistration

I have applied these two for 7.4 now.

> software node: fix device_add_software_node() kernel doc
> software node: ignore primary nodes in device_remove_software_node()
> driver core: platform: warn on bad fwnode assignment
> driver core: platform: tests: fix swnode reuse test description
> software node: fix software_node_notify() primary node comment
> device property: fix fwnode_get_next_child_node() comments

Johan