Commit 0f21e527 authored by vulab's avatar vulab Committed by Liu Chuang
Browse files

i2c: Fix a potential use after free

stable inclusion
from stable-v4.19.307
commit 23a191b132cd87f746c62f3dc27da33683d85829
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I946KM
CVE: CVE-2019-25162

Reference: https://git.kernel.org/stable/c/23a191b132cd87f746c62f3dc27da33683d85829



---------------------------------------------------------------

[ Upstream commit e4c72c06 ]

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: 611e12ea ("i2c: core: manage i2c bus device refcount in i2c_[get|put]_adapter")
Signed-off-by: default avatarXu Wang <vulab@iscas.ac.cn>
[wsa: added comment to the code, added Fixes tag]
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLiu Chuang <liuchuang40@huawei.com>
parent 415aa2f1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment