From patchwork Thu Jul 20 16:00:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108408 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2316679qge; Thu, 20 Jul 2017 09:01:55 -0700 (PDT) X-Received: by 10.84.231.197 with SMTP id g5mr4875753pln.71.1500566515344; Thu, 20 Jul 2017 09:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500566515; cv=none; d=google.com; s=arc-20160816; b=pj6A8CZW64/zOpARppcbeAzPPxQsQ0Jw2zse9YsHrD1VRXNkM/lLoHTWZipCuAsvRg fQbT7Xrxo+1hfDsA2dy8sBuM147AkOdX9WVm0deI6OEzzOBJWczHkI3aBbx95/piFAzI ldbaRI/dTevqw2HeEKOufaJlsZgDJBR0agTBSHtSGYO1kOsRfPSFES3xsXBfUpmEQV7i 4sqIjFuhlZnNANyLef8IfXj0SpyRz+mIzXODqJywY/CJCYYfQCYkhtdov+LuQETYG+xu ms0SCflKPR/KWupkAvRktB/Jnjb402njHKeT2Q+n5pCYyKZ9j4/iABT/Rv4HLNRGRtBS G5YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XH0WGa+z2MnbFj9RVVS/NG4Uj3w/mw0UhQa4jPulxSA=; b=hn2swxxtR1Sb6wQNJGONNnY1m+LwJuPss8ue3/DhoY2fyxF33n4haUxnH8O5qSsWho ygVqVswXMzvjYe9iek7iwQ5w3sjLcysRMYdWOWQ2Zl1+EnApnM+jP/gqkxfLpvnWhx46 UFxYRgkfnlZdGOuv0PGzzF3rphb7auBUsfCAeEQvTp/mJpdygO3ndwDRFos1U364ztLq VMqecMXO8qS2a1tTX1+D2fsXGo3ooNinKFtRM5ancAZKQ1Dxq4rT58Kw3rMVDUYj6XsP 6lQC5S9eWft3qb6CN7qlH8O9qr6IxWv9ixj7Eb66Wk1D4EBSjRzjgJVM+0izgm42gNXb eWvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q66si1815676pga.353.2017.07.20.09.01.54; Thu, 20 Jul 2017 09:01:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936603AbdGTQBu (ORCPT + 25 others); Thu, 20 Jul 2017 12:01:50 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59860 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934497AbdGTQBs (ORCPT ); Thu, 20 Jul 2017 12:01:48 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MJkO4-1dZKLg09Bs-00196Q; Thu, 20 Jul 2017 18:01:16 +0200 From: Arnd Bergmann To: Darren Hart , Andy Shevchenko Cc: Arnd Bergmann , Hans de Goede , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Date: Thu, 20 Jul 2017 18:00:50 +0200 Message-Id: <20170720160114.3261176-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:HhFqqrI2AP8d1rmq6s/oUfMxtoXPvNTOtmL3AIVdeNr2Gem122E st7v7SoswNJryxeIAScNssYrXA4NwFeYrtrmfnecBajzLUICEKENxDUAoB36RFTtSLa0g5G UqFOgrNnwwOVEcGsJ7bwBbTTfg7p26yks4be2p//PeczdOr8GW4qEetlUrqr7GaoK/WrvX3 gCN35tw4XMPEqQSW0QmuA== X-UI-Out-Filterresults: notjunk:1; V01:K0:e/yY5OfflWQ=:17ejynq8vaNxEo2ltnfjgv sjHdXvNu0Zp9Yz5xho5nW0nlk1OMGkp/UMlgePfOE0Vu6GlzBO2tkHutgendjSwFm8epYnGXk dFL54AEfpdFnTRxpbCNjIYzI5/uRaGTuTKo5dYPn7Ji5cCugHUWpqSXDMTkYNWatjn/0G0GFK nz76Utn8faA3x16JBgiZ3dKZ1vhS//DYgim5LFeY7jQhgXblWFZqLeIKGiaJWkH6jOF+EGFTO dS3H4k1R22tM0fliUAMyx77rBM/TfZErReVUKGL7Bp5Bb5i2CSExTdP4rn94gCrPOqUz15x2I SA0IVUSNsw3nuFa0Nu4wul4Sn0wgmQ3eaqm9JsNAa529nLX5e7G7IO234pNsjPfLexjQSiKYe c/dNDJ/eTvTM2FsN0gBQ897TTIfbLmooMjbuvTnKPWbPHBrWT+WOu9DME+lgeOo+A0w6oIKCG rqjDSd17cVQiVK0oNaTHG9s/NqKIis2QcoWcx9Mbj6tMxaWLZA+XBatburqFzzmHsrVnK642S jXyV+Lbo9/PdGGCaF6Wy+X/XCm2Q/NGNQnCsg7GPitGdvlrBuosk2Iv8HfLlK7Eu3y4+PXJ8B mMTYH6dCfjOQ1yrJbISK7jpC160dZeUsOIUQcDYPxOB1zZzCUeqcoxGqx9Yn2U/MsYq9/ygOu YEAL0iydytjalZHO3L9WUUlbtCOHPycZyRmkFuX3LVFvTi3SUCgq/rYfpAVSeYKXA0pKvr7/P 8RbgAx6x1ZKY3ZPy4Du25zFOCbdooNsqCc6aMA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new driver fails to build without INPUT_POLLDEV drivers/platform/x86/peaq-wmi.o: In function `peaq_wmi_exit': peaq-wmi.c:(.exit.text+0x1c): undefined reference to `input_unregister_polled_device' drivers/platform/x86/peaq-wmi.o: In function `peaq_wmi_init': peaq-wmi.c:(.init.text+0x23): undefined reference to `input_allocate_polled_device' peaq-wmi.c:(.init.text+0x18e): undefined reference to `input_register_polled_device' For some reason, all other drivers that need this use 'select' here rather than 'depends on', so I'm doing the same. Fixes: 13bb0fd5519d ("platform/x86: peaq-wmi: Add new peaq-wmi driver") Signed-off-by: Arnd Bergmann --- drivers/platform/x86/Kconfig | 1 + 1 file changed, 1 insertion(+) -- 2.9.0 diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 2b209f5d42ff..d9238e9ff54a 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -672,6 +672,7 @@ config PEAQ_WMI tristate "PEAQ 2-in-1 WMI hotkey driver" depends on ACPI_WMI depends on INPUT + select INPUT_POLLDEV help Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s. From patchwork Thu Jul 20 16:00:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 108410 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2317139qge; Thu, 20 Jul 2017 09:02:16 -0700 (PDT) X-Received: by 10.99.111.70 with SMTP id k67mr4407376pgc.214.1500566536012; Thu, 20 Jul 2017 09:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500566536; cv=none; d=google.com; s=arc-20160816; b=xJSA+OgC3uWYNQoqo5Rv6ktSWDwX/rJU3CkoJjmIM1l8W+HMBuB1QW/AQex9zLwl26 OlYYUCgSlzEgpD4q75EeOxtei70n3y3h3SsbbNhx7l/TBqVLjEgYGfhyHDu9viCA+k9y RDWFIlByeAkZoMd6uX25yd0l43joMja6CmhvoRhOt+PQePC+V0ZoS9GDANWHYrAPCil/ dscBiqlqsVigHMzalPzUHJiOkZh8G9s8V23AR+kYFuuk2ESSigVVmnypy+PJDQzg81xd xC4Lh1yF4EtEl3WRxewuToRDRLudlPX8iZA0RrG6dDT0rV683l+D8oiDctRbp/k7Lcp9 7J5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uxlQTYRG56S4zQy8QRSS2TQpTNiKDURPTrUHq79J2AY=; b=UOmQCa8cBiIBjIzv4nzN/Fth3/IetmP126bNHaQyPS47u5JtjLwlL4jpW2xH9NTyC/ HZ3wW6vlb4HthjF+hmLjiTrf7wTayrqXXtZmUBmgGrgf3hyjDDYTr+UhSPQLvocuMquG 3DsDglPvmxFoj3YnU9ADj2QkzTBVAgz0He5Gs+PSkNk3U2Nc+dpk8nmNR3YAVrZzoFQ4 Vwlaa9XMusuYZ0+ubXY4gMRJxug9ftUdqBELiqThgtavxIEbAPovghNQnQ/ieWw6ayFw XFxpoUxoSTIDMPz3xMQdTzjFkV4PkcrrKcgEqXRoLFak0/egfEIdR8iiitb5Uhe+hAA0 TECw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q66si1815676pga.353.2017.07.20.09.02.15; Thu, 20 Jul 2017 09:02:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936613AbdGTQCN (ORCPT + 25 others); Thu, 20 Jul 2017 12:02:13 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:53116 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934497AbdGTQCK (ORCPT ); Thu, 20 Jul 2017 12:02:10 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lwqoy-1dedpA0XpQ-016QT8; Thu, 20 Jul 2017 18:01:44 +0200 From: Arnd Bergmann To: Darren Hart , Andy Shevchenko Cc: Arnd Bergmann , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Date: Thu, 20 Jul 2017 18:00:51 +0200 Message-Id: <20170720160114.3261176-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170720160114.3261176-1-arnd@arndb.de> References: <20170720160114.3261176-1-arnd@arndb.de> X-Provags-ID: V03:K0:5oubkWhIBVIIoSuoKS6I3K1gpJmGoZAt5h9lk70flgc/vSlp5iH R5RuHCLA4NlBw/x5FwmqTragBbf3LXz+g24f9+XT7X9573EV6lO9pJy7j/MlreodaMLW7M+ iHnfMDzzCfa00wDg55AhJitfyZ29D6os1tOokHY/eiEJtwvSX3PBeUCXAnBUO352Oskqsed mv9wG0OXirs92L22oFQIw== X-UI-Out-Filterresults: notjunk:1; V01:K0:/VuXnIfv0xU=:nTbg/E+DxfZoe4FQNfs8bN NGGrxX6GW3lrnV/NOjIU98BvTmHKOgAep/FKEB1lJe0eFGByxb+e079OFC9mvSyx1jRs0/FDW XGHsBpcgoOM73leTWHeMu4BxkqA/i2TkMbgmkFcEtBKd83B+4XzMDsnrClfkMkm6RRw2r02jR w4+YrruWSfG29GK14xFwwrYgqJ5dTuKaaDXmjTt6US5mqe+cvElabvipY/J/PASNyqFH0jqIB DZdph/XI41Dh0TbTRHBLhwo/uZjQkw1HJRMViIJJI2sxjzJoYSWqoSPZtL+Zb8YwOPt3GccMu rAfNpESKWetM/5Z5J/cGGjYOA8RsBSJsnbtcseKedkQjGYObD4Utrp5hV9k3QQizkSuRkWhBE 3hJCTY7YDoceplUdhQttrNr48AkCYu0F6OIMreT5kXG8MAjdpGEuz1+GLkA6aC0IOOYKx/WgY cUoq4Q3A5PdpvIvQ8eqsNT4bAIO7lopljFYKHsNj1J7vhZ2mY+Uc5qHoTrDyVwP0HDiUY+hrZ bfauoybcd6j72yfaD0kE3NCcubaCKXMVGhEu2Nkje40dI62M2NDwoUNGAsbUFgeescbRvwjWx n3hnUlGsuT1dYW6Hcm8ByzKe79206krmTE57UP53jVbYo8BDjVcfVgf3Sndt0VYJABx9CVUxC I3/gqWyM+aLbQWcJX0GT/G16OaVdnhkwF1L0McOZeiGiCZYhprLzj0H7sy9KnyJGSdNJxvmMI QmJeBvuqX41XixQC7ymePitoA9AwrfmuxPIVNw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc points out a possible format string overflow for a large value of 'zone': drivers/platform/x86/alienware-wmi.c: In function 'alienware_wmi_init': drivers/platform/x86/alienware-wmi.c:461:24: error: '%02X' directive writing between 2 and 8 bytes into a region of size 6 [-Werror=format-overflow=] sprintf(buffer, "zone%02X", i); ^~~~ drivers/platform/x86/alienware-wmi.c:461:19: note: directive argument in the range [0, 2147483646] sprintf(buffer, "zone%02X", i); ^~~~~~~~~~ drivers/platform/x86/alienware-wmi.c:461:3: note: 'sprintf' output between 7 and 13 bytes into a destination of size 10 This replaces the 'int' variable with an 'u8' to make sure it always fits, renaming the variable to 'zone' for clarity. Unfortunately, gcc-7.1.1 still warns about it with that change, which seems to be unintended by the gcc developers. I have opened a bug against gcc with a reduced test case. As a workaround, I also change the format string to use "%02hhX", which shuts up the warning in that version. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483 Link: https://patchwork.ozlabs.org/patch/788415/ Suggested-by: Andy Shevchenko Signed-off-by: Arnd Bergmann --- v2: completely rewrite the patch after discussing with Andy --- drivers/platform/x86/alienware-wmi.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) -- 2.9.0 diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c index 0831b428c217..c56a9ecba959 100644 --- a/drivers/platform/x86/alienware-wmi.c +++ b/drivers/platform/x86/alienware-wmi.c @@ -255,12 +255,12 @@ static int parse_rgb(const char *buf, struct platform_zone *zone) static struct platform_zone *match_zone(struct device_attribute *attr) { - int i; - for (i = 0; i < quirks->num_zones; i++) { - if ((struct device_attribute *)zone_data[i].attr == attr) { + u8 zone; + for (zone = 0; zone < quirks->num_zones; zone++) { + if ((struct device_attribute *)zone_data[zone].attr == attr) { pr_debug("alienware-wmi: matched zone location: %d\n", - zone_data[i].location); - return &zone_data[i]; + zone_data[zone].location); + return &zone_data[zone]; } } return NULL; @@ -420,7 +420,7 @@ static DEVICE_ATTR(lighting_control_state, 0644, show_control_state, static int alienware_zone_init(struct platform_device *dev) { - int i; + u8 zone; char buffer[10]; char *name; @@ -457,19 +457,19 @@ static int alienware_zone_init(struct platform_device *dev) if (!zone_data) return -ENOMEM; - for (i = 0; i < quirks->num_zones; i++) { - sprintf(buffer, "zone%02X", i); + for (zone = 0; zone < quirks->num_zones; zone++) { + sprintf(buffer, "zone%02hhX", zone); name = kstrdup(buffer, GFP_KERNEL); if (name == NULL) return 1; - sysfs_attr_init(&zone_dev_attrs[i].attr); - zone_dev_attrs[i].attr.name = name; - zone_dev_attrs[i].attr.mode = 0644; - zone_dev_attrs[i].show = zone_show; - zone_dev_attrs[i].store = zone_set; - zone_data[i].location = i; - zone_attrs[i] = &zone_dev_attrs[i].attr; - zone_data[i].attr = &zone_dev_attrs[i]; + sysfs_attr_init(&zone_dev_attrs[zone].attr); + zone_dev_attrs[zone].attr.name = name; + zone_dev_attrs[zone].attr.mode = 0644; + zone_dev_attrs[zone].show = zone_show; + zone_dev_attrs[zone].store = zone_set; + zone_data[zone].location = zone; + zone_attrs[zone] = &zone_dev_attrs[zone].attr; + zone_data[zone].attr = &zone_dev_attrs[zone]; } zone_attrs[quirks->num_zones] = &dev_attr_lighting_control_state.attr; zone_attribute_group.attrs = zone_attrs; @@ -484,9 +484,9 @@ static void alienware_zone_exit(struct platform_device *dev) sysfs_remove_group(&dev->dev.kobj, &zone_attribute_group); led_classdev_unregister(&global_led); if (zone_dev_attrs) { - int i; - for (i = 0; i < quirks->num_zones; i++) - kfree(zone_dev_attrs[i].attr.name); + u8 zone; + for (zone = 0; zone < quirks->num_zones; zone++) + kfree(zone_dev_attrs[zone].attr.name); } kfree(zone_dev_attrs); kfree(zone_data);