Re: [PATCH v2 2/8] i2c: core: fix swnode use-after-free on client deregistration

From: Wolfram Sang

Date: Fri Nov 13 2026 - 17:19:29 EST


On Tue, Nov 10, 2026 at 09:51:18AM +0100, Johan Hovold wrote:
> If a client has both a primary and a secondary firmware node, the
> secondary node is accessed via the ->secondary pointer of the primary
> node.
>
> Use a temporary variable to track whether the firmware node is a
> software node and remove any software node before dropping its reference
> to avoid a use-after-free in device_remove_software_node() when
> accessing the secondary firmware node.
>
> Fixes: df6d7277e552 ("i2c: core: Do not dereference fwnode in struct device")
> Fixes: 1c24e5fc0c70 ("i2c: core: Fix double-free of fwnode in i2c_unregister_device()")
> Cc: stable@xxxxxxxxxxxxxxx # 6.16
> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Cc: Hans de Goede <hansg@xxxxxxxxxx>
> Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>

Looks reasonable to me. Thanks for doing this and the cleanup in patch
4/8.

Acked-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature