From patchwork Mon Jan 4 21:26:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 7951311 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F3939F6CD for ; Mon, 4 Jan 2016 21:27:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE969202FE for ; Mon, 4 Jan 2016 21:27:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6D60201FE for ; Mon, 4 Jan 2016 21:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbcADV1j (ORCPT ); Mon, 4 Jan 2016 16:27:39 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:33950 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751523AbcADV1f (ORCPT ); Mon, 4 Jan 2016 16:27:35 -0500 Received: by mail-wm0-f50.google.com with SMTP id u188so1214731wmu.1; Mon, 04 Jan 2016 13:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=AiS/gpDtwotFSuny9RpX8B8vjWA+fUfs32EQ6w2hiR0=; b=lU1Wa0vez6VXjvwM5ljdmeDS11CjmaF7p9u/SvFBnE5/o4VI9wYuofuYWcbokKuUxs 5g9oQd9RYQOjwF8P9XgxFmIql9gvL2s2PIwhSyWzvLyPt9Kg8kbLasKoEfWicVDNY+3I bdUAnkPESL9DV+5QcPIRyz0X7MD5mnQgptmJg5fySFbHIa4w5Kd+dc+WEYABn10exg49 0GJOA6hPOro/g8dJerghVm/nLTZ9nrKOrnAr/pWRpf4VbEZIB4L0usaXu4bjIC25tMZG jOzj5j8RGK012+CgevkD5OULpr0i1UOxr2TMcwnkaWPHksxBw8CiXDz7yEctAniJd3VZ bTIQ== X-Received: by 10.28.186.87 with SMTP id k84mr477224wmf.13.1451942854500; Mon, 04 Jan 2016 13:27:34 -0800 (PST) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id m16sm414890wmb.13.2016.01.04.13.27.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jan 2016 13:27:33 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Matthew Garrett , Darren Hart , Gabriele Mazzotta , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Cc: Andy Lutomirski , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2 2/2] dell-wmi: Process only one event on devices with interface version 0 Date: Mon, 4 Jan 2016 22:26:36 +0100 Message-Id: <1451942796-26574-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1451942796-26574-1-git-send-email-pali.rohar@gmail.com> References: <1450991926-20937-1-git-send-email-pali.rohar@gmail.com> <1451942796-26574-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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). So to prevent reading garbage from buffer we will process only first one event on devices with WMI interface version 0. Signed-off-by: Pali Rohár --- drivers/platform/x86/dell-wmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 1ad7a7b..5db9efb 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];