Unverified Commit 67e7eb4c authored by Armin Wolf's avatar Armin Wolf Committed by Ilpo Järvinen
Browse files

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: d0504796 ("platform/x86: Add Uniwill laptop driver")
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20260218005101.73680-3-W_Armin@gmx.de


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 2d53dfac
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1359,6 +1359,9 @@ static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action

	switch (action) {
	case UNIWILL_OSD_BATTERY_ALERT:
		if (!uniwill_device_supports(data, UNIWILL_FEATURE_BATTERY))
			return NOTIFY_DONE;

		mutex_lock(&data->battery_lock);
		list_for_each_entry(entry, &data->batteries, head) {
			power_supply_changed(entry->battery);