Re: [PATCH v3 07/10] i2c: core: fix adapter registration race
From: Wolfram Sang
Date: Thu Jun 04 2026 - 05:07:20 EST
On Mon, May 11, 2026 at 04:37:12PM +0200, Johan Hovold wrote:
> Adapters can be looked up based on their id using i2c_get_adapter()
> which takes a reference to the embedded struct device.
>
> Make sure that the adapter (including its struct device) has been
> initialised before adding it to the IDR to avoid accessing uninitialised
> data which could, for example, lead to NULL-pointer dereferences or
> use-after-free.
>
> Note that the i2c-dev chardev, which is registered from a bus notifier,
> currently uses i2c_get_adapter() so the adapter needs to be added to the
> IDR before registration.
>
> Fixes: 6e13e6418418 ("i2c: Add i2c_add_numbered_adapter()")
> Cc: stable@xxxxxxxxxxxxxxx # 2.6.22
> Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
Attachment:
signature.asc
Description: PGP signature