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@vger.kernel.org # 2.6.22 > Signed-off-by: Johan Hovold Reviewed-by: Wolfram Sang