HID: mcp2221: Set driver data before I2C adapter add
authorHamish Martin <hamish.martin@alliedtelesis.co.nz>
Wed, 25 Oct 2023 03:55:10 +0000 (16:55 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2023 16:01:58 +0000 (17:01 +0100)
commit2afe67cfe8f121b1b9dd244a0edc01b89cd65813
tree951abfc5d2d71bfabf8e9a1a5b0f1983de6f2ab6
parent086f91f3ce3b8d13cb794b955002b74444a384fa
HID: mcp2221: Set driver data before I2C adapter add

[ Upstream commit f2d4a5834638bbc967371b9168c0b481519f7c5e ]

The process of adding an I2C adapter can invoke I2C accesses on that new
adapter (see i2c_detect()).

Ensure we have set the adapter's driver data to avoid null pointer
dereferences in the xfer functions during the adapter add.

This has been noted in the past and the same fix proposed but not
completed. See:
https://lore.kernel.org/lkml/ef597e73-ed71-168e-52af-0d19b03734ac@vigem.de/

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hid/hid-mcp2221.c