Skip to content

Commit 67e7eb4

Browse files
Wer-Wolfij-intel
authored andcommitted
platform/x86: uniwill-laptop: Fix crash on unexpected battery event
On devices that have not UNIWILL_FEATURE_BATTERY set, the underlying hardware might still send the UNIWILL_OSD_BATTERY_ALERT event. In such a situation, the driver will access uninitialized data structures when handling said event. Prevent this by only handling the UNIWILL_OSD_BATTERY_ALERT event when UNIWILL_FEATURE_BATTERY is set. Fixes: d050479 ("platform/x86: Add Uniwill laptop driver") Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://patch.msgid.link/20260218005101.73680-3-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 2d53dfa commit 67e7eb4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/platform/x86/uniwill/uniwill-acpi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,9 @@ static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action
13591359

13601360
switch (action) {
13611361
case UNIWILL_OSD_BATTERY_ALERT:
1362+
if (!uniwill_device_supports(data, UNIWILL_FEATURE_BATTERY))
1363+
return NOTIFY_DONE;
1364+
13621365
mutex_lock(&data->battery_lock);
13631366
list_for_each_entry(entry, &data->batteries, head) {
13641367
power_supply_changed(entry->battery);

0 commit comments

Comments
 (0)