]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: Fix a potential use after free
authorXu Wang <vulab@iscas.ac.cn>
Fri, 27 Dec 2019 09:34:32 +0000 (09:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:17:38 +0000 (11:17 +0200)
commita1d48c01c0f3b4c08513f72ceffb51cfa1a9d2c8
treeda218cd9967c6d7eb076f12d5fd29cd77c068f6d
parent0f8d38f783c22a9765a2644057f30aa09939c1ee
i2c: Fix a potential use after free

[ Upstream commit 07c2a9e4a0f7f51fa9b67a67744ce620fda18544 ]

Free the adap structure only after we are done using it.
This patch just moves the put_device() down a bit to avoid the
use after free.

Fixes: f53eb995e73c ("i2c: core: manage i2c bus device refcount in i2c_[get|put]_adapter")
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
[wsa: added comment to the code, added Fixes tag]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/i2c-core-base.c