From patchwork Thu Dec 24 21:18:46 2015 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: 7920021 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 E875E9F1AF for ; Thu, 24 Dec 2015 21:19:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CB9B20444 for ; Thu, 24 Dec 2015 21:19:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 364C4203A1 for ; Thu, 24 Dec 2015 21:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753640AbbLXVTo (ORCPT ); Thu, 24 Dec 2015 16:19:44 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37124 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753343AbbLXVTG (ORCPT ); Thu, 24 Dec 2015 16:19:06 -0500 Received: by mail-wm0-f53.google.com with SMTP id p187so192587829wmp.0; Thu, 24 Dec 2015 13:19:05 -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=CfvFyHbBx4VqDPtarMMJA12JZspit/mtC73yiS6E5Og=; b=TJujUc3RVtIhntvJYoaN/fIPGhHsB6h/etpwtdxP6owEEOEPGFK1nFPwmqSX8CTnBQ HOwP2M1wP7kAUHQIbVcPu97QSGJgt8B8XYVCrfe1TxNY//HRziJLCE0BphPLlZgf7N07 +Ws70RXyMFQc56ZIUztSagSWDHzjBmUauZ2647q9ukFOdEC5o4wY+XyJ1/+qjs6vMTup D2+eLcW0NGd5uN0oOfDTepNos4KMQiSV4P/PovOzcmV68/OuqwB+NPJFLaw4/SmK6kxa F9AWDAhk82kDmtGMKGWUKWFGH0ynot9eB5jlYJMidz3vtXC7XfS0iBTSv1uAygOR1MfO 3O4Q== X-Received: by 10.194.190.82 with SMTP id go18mr41452839wjc.148.1450991944605; Thu, 24 Dec 2015 13:19:04 -0800 (PST) Received: from localhost.localdomain (ip-88-212-34-237.antik.sk. [88.212.34.237]) by smtp.gmail.com with ESMTPSA id un6sm42895266wjc.34.2015.12.24.13.19.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Dec 2015 13:19:04 -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 2/2] dell-wmi: Process only one event on devices with interface version 0 Date: Thu, 24 Dec 2015 22:18:46 +0100 Message-Id: <1450991926-20937-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1450991926-20937-1-git-send-email-pali.rohar@gmail.com> References: <1450991926-20937-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=ham 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 09ee8ed..62f2f7a 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];