From patchwork Sat May 27 11:55:34 2017 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: 9751851 X-Patchwork-Delegate: dvhart@infradead.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 196456037E for ; Sat, 27 May 2017 11:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB7427B81 for ; Sat, 27 May 2017 11:56:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3EA82845C; Sat, 27 May 2017 11:56:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94F2627B81 for ; Sat, 27 May 2017 11:56:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756518AbdE0L4E (ORCPT ); Sat, 27 May 2017 07:56:04 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35844 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756051AbdE0L4D (ORCPT ); Sat, 27 May 2017 07:56:03 -0400 Received: by mail-wm0-f67.google.com with SMTP id k15so7967306wmh.3; Sat, 27 May 2017 04:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EyoxZ+K1xBMb9oJMibiuTgNsmTN7qzfknKRTfNcBVzg=; b=Gumd9Ba3AkVgJN/nKMbUGhca6v/e3YleI97ic3+5CzOz7fvvP0yCBWgnPqLJI6Fxg3 rwFaEI6doTOaaGzBZJx5z+2S3MDnqnZPp5pwK0h/yEvk/NcS24PDZYXla3/jJolTPqlI FQ79BUvyoBE7W2D30XWv3Hesg2EGEqsNdd9MWn+sY9iF1+ObfpzDLovjTFrvBCnjV7/v 41Eu3XR3dTtcs7Xr/Z/OCP3IAKY3mYFZq9+oYFzr78f10K9hTYmWi7IOwCVXvrONKMMo qivhWv/SYS8cZtfyrZr4c9piVlWwRF43gykXnwAvusvB6/IxzUbotbl/V843M1NGSBoB LMZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EyoxZ+K1xBMb9oJMibiuTgNsmTN7qzfknKRTfNcBVzg=; b=gu8i+fQohdZQwg06uxVRq5uEqBAfYR2BsAuP6mw9PoOeRVGbNOOz6nRJ+kgAw5dbra EDj41Z/DHt44UMxRIdnqWEL9xcBG4V6OYsY/LdUA3WAWT4iqqz9Qxp6bbsvFOaZEYcDH Qevv/ZsmQ8jr9p4Vpkmb31vjdIocMqeeq9tNiugl2X4/mRQCMh40GBBrxIvlp+x8Q5Rb hunPBMuknh/7A+LXdqC7Adqim1O/5meWyWSkZ+ujeu890X8ehMFp9v4EFKlKEy+wGRJ0 RDmR0K577BOf6BMbW+KEizMP8uc2pCzayI4+QhTKetiEbgkA2KIJyb7fcxnpUY2/kV2G Z4nQ== X-Gm-Message-State: AODbwcDx8lweWG+xXn1iwuO2m/e4Cul2S4/qt13cLkuhicKC8oI3g2Yy IU9vrIMFO0XUHw== X-Received: by 10.28.174.131 with SMTP id x125mr4716144wme.32.1495886161696; Sat, 27 May 2017 04:56:01 -0700 (PDT) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id m14sm19636363wmi.2.2017.05.27.04.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 May 2017 04:56:01 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Darren Hart , Andy Shevchenko , Andy Lutomirski Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH] RFC: platform/x86: wmi: Fix check for method instance number Date: Sat, 27 May 2017 13:55:34 +0200 Message-Id: <1495886134-8276-1-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 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-Virus-Scanned: ClamAV using ClamSMTP instance_count defines number of instances of data block and instance itself is indexed from zero, which means first instance has number 0. Therefore check for invalid instance should be non-strict inequality. Signed-off-by: Pali Rohár --- I'm marking this patch as RFC because it is not tested at all and probably could break existing WMI drivers. Some WMI drivers pass instance number 1 and I'm not sure if ACPI-WMI bytecode for those machines has really two instances. In more cases ACPI-WMI bytecode does not check instance number if supports only one instance. So then any instance id can be used for correct execution of ACPI-WMI method. So this patch is open for discussion. --- drivers/platform/x86/wmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index cd7045f..df63037 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -191,7 +191,7 @@ acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, if (!(block->flags & ACPI_WMI_METHOD)) return AE_BAD_DATA; - if (block->instance_count < instance) + if (block->instance_count <= instance) return AE_BAD_PARAMETER; input.count = 2; @@ -250,7 +250,7 @@ struct acpi_buffer *out) block = &wblock->gblock; handle = wblock->handle; - if (block->instance_count < instance) + if (block->instance_count <= instance) return AE_BAD_PARAMETER; /* Check GUID is a data block */ @@ -323,7 +323,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, block = &wblock->gblock; handle = wblock->handle; - if (block->instance_count < instance) + if (block->instance_count <= instance) return AE_BAD_PARAMETER; /* Check GUID is a data block */