]> www.infradead.org Git - users/dwmw2/linux.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>
Sun, 21 Aug 2022 13:15:40 +0000 (15:15 +0200)
commit81cb31756888bb062e92d2dca21cd629d77a46a9
tree3d22f1a23479c337caf07da36040355f5d61b0a0
parentd0412d8f693e6f00b6cda80cc3ae1fbc7c14d392
i2c: Fix a potential use after free

[ Upstream commit e4c72c06c367758a14f227c847f9d623f1994ecf ]

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: 611e12ea0f12 ("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