diff options
author | Gaosheng Cui <cuigaosheng1@huawei.com> | 2022-11-17 11:44:23 +0800 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2022-11-20 06:04:16 -0800 |
commit | e2a87785aab0dac190ac89be6a9ba955e2c634f2 (patch) | |
tree | cfe97d900185692d0ee9c1fae853a0f43a0f206c | |
parent | 3b7f98f237528c496ea0b689bace0e35eec3e060 (diff) | |
download | linux-stable-e2a87785aab0dac190ac89be6a9ba955e2c634f2.tar.gz linux-stable-e2a87785aab0dac190ac89be6a9ba955e2c634f2.tar.bz2 linux-stable-e2a87785aab0dac190ac89be6a9ba955e2c634f2.zip |
hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
Smatch report warning as follows:
drivers/hwmon/ibmpex.c:509 ibmpex_register_bmc() warn:
'&data->list' not removed from list
If ibmpex_find_sensors() fails in ibmpex_register_bmc(), data will
be freed, but data->list will not be removed from driver_data.bmc_data,
then list traversal may cause UAF.
Fix by removeing it from driver_data.bmc_data before free().
Fixes: 57c7c3a0fdea ("hwmon: IBM power meter driver")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Link: https://lore.kernel.org/r/20221117034423.2935739-1-cuigaosheng1@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/ibmpex.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index f6ec165c0fa8..1837cccd993c 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c @@ -502,6 +502,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev) return; out_register: + list_del(&data->list); hwmon_device_unregister(data->hwmon_dev); out_user: ipmi_destroy_user(data->user); |