]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: imx: Make sure to unregister adapter on remove()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 20 Jul 2022 15:09:33 +0000 (17:09 +0200)
committerWolfram Sang <wsa@kernel.org>
Sun, 21 Aug 2022 08:27:33 +0000 (10:27 +0200)
commit442a362f11b930a4d901778a34e920be665dc1e4
treee422c6b366d11f3d8e99484c850ebfd0a09de63f
parent076df2fd293c4fd932f8ce1a732a403f2184ca1a
i2c: imx: Make sure to unregister adapter on remove()

If for whatever reasons pm_runtime_resume_and_get() fails and .remove() is
exited early, the i2c adapter stays around and the irq still calls its
handler, while the driver data and the register mapping go away. So if
later the i2c adapter is accessed or the irq triggers this results in
havoc accessing freed memory and unmapped registers.

So unregister the software resources even if resume failed, and only skip
the hardware access in that case.

Fixes: cc098df8d65c ("i2c: imx: add runtime pm support to improve the performance")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-imx.c