From: Pali Rohár Date: Mon, 4 Jan 2016 21:26:36 +0000 (+0100) Subject: dell-wmi: Process only one event on devices with interface version 0 X-Git-Tag: MMI-PSA29.97-13-9~8666^2~8 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=481fe5be821c3d04f986e4061de42e1209a62374;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git dell-wmi: Process only one event on devices with interface version 0 BIOS/ACPI on devices with WMI interface version 0 does not clear buffer before filling it. So next time when BIOS/ACPI send WMI event which is smaller as previous then it contains garbage in buffer from previous event. BIOS/ACPI on devices with WMI interface version 1 clears buffer and sometimes send more events in buffer at one call. Since commit 83fc44c32ad8 ("dell-wmi: Update code for processing WMI events") dell-wmi process all events in buffer (and not just first). To prevent reading garbage from the buffer we process only the first event on devices with WMI interface version 0. Signed-off-by: Pali Rohár Tested-by: Gabriele Mazzotta Signed-off-by: Darren Hart --- diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 1ad7a7b41574..5db9efbde5b9 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -237,6 +237,22 @@ static void dell_wmi_notify(u32 value, void *context) buffer_end = buffer_entry + buffer_size; + /* + * BIOS/ACPI on devices with WMI interface version 0 does not clear + * buffer before filling it. So next time when BIOS/ACPI send WMI event + * which is smaller as previous then it contains garbage in buffer from + * previous event. + * + * BIOS/ACPI on devices with WMI interface version 1 clears buffer and + * sometimes send more events in buffer at one call. + * + * So to prevent reading garbage from buffer we will process only first + * one event on devices with WMI interface version 0. + */ + if (dell_wmi_interface_version == 0 && buffer_entry < buffer_end) + if (buffer_end > buffer_entry + buffer_entry[0] + 1) + buffer_end = buffer_entry + buffer_entry[0] + 1; + while (buffer_entry < buffer_end) { len = buffer_entry[0];