summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2026-10-30 08:41:11 -0700
committerGuenter Roeck <linux@roeck-us.net>2026-11-02 07:00:04 -0800
commitdc992efeace99e479aec7a8f0c49a9493c729606 (patch)
treebd60a5177a2b1f41a159f431ac0cf92d520385f6 /scripts
parent59d586c9e47d1205563bc9b5a5d443adc3ba5bc5 (diff)
hwmon: (hp-wmi-sensors) Avoid global struct mutation
In the HP WMI sensors driver, make_chip_info() assigns a device-managed memory allocation to a static global structure, resulting in a use-after-free when the device unbinds. During hp_wmi_sensors_probe(), make_chip_info() dynamically allocates a hwmon_channel_info array using devm_kcalloc() and assigns it to the static global hp_wmi_chip_info.info pointer. If multiple instances probe sequentially or concurrently, the shared global pointer is overwritten by each new device. When any device unbinds, its devm-managed memory is automatically freed, leaving the global hp_wmi_chip_info struct and any other active device instances with a dangling pointer. Subsequent accesses by the hwmon core (such as thermal zone reads) will dereference this freed memory, causing a use-after-free. While this is not supposed to happen in the real world (there should only be one instance of the driver in any system), modifying global structures is undesirable and should be avoided whenever possible. Allocate struct hwmon_chip_info as part of struct hp_wmi_sensors instead and initialize it in make_chip_info() to avoid mutating the global structure. Fixes: 23902f98f8d4 ("hwmon: add HP WMI Sensors driver") Cc: stable@vger.kernel.org Cc: James Seo <james@equiv.tech> Acked-by: James Seo <james@equiv.tech Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions