* [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV
@ 2017-07-20 16:00 Arnd Bergmann
2017-07-20 16:00 ` [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Arnd Bergmann
2017-07-21 0:02 ` [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Darren Hart
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2017-07-20 16:00 UTC (permalink / raw)
To: Darren Hart, Andy Shevchenko
Cc: Arnd Bergmann, Hans de Goede, platform-driver-x86, linux-kernel
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 <arnd@arndb.de>
---
drivers/platform/x86/Kconfig | 1 +
1 file changed, 1 insertion(+)
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.
--
2.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning 2017-07-20 16:00 [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Arnd Bergmann @ 2017-07-20 16:00 ` Arnd Bergmann 2017-07-24 9:22 ` Andy Shevchenko 2017-07-21 0:02 ` [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Darren Hart 1 sibling, 1 reply; 5+ messages in thread From: Arnd Bergmann @ 2017-07-20 16:00 UTC (permalink / raw) To: Darren Hart, Andy Shevchenko Cc: Arnd Bergmann, platform-driver-x86, linux-kernel 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 <andy@infradead.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- v2: completely rewrite the patch after discussing with Andy --- drivers/platform/x86/alienware-wmi.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) 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); -- 2.9.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning 2017-07-20 16:00 ` [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Arnd Bergmann @ 2017-07-24 9:22 ` Andy Shevchenko 2017-07-25 7:23 ` Arnd Bergmann 0 siblings, 1 reply; 5+ messages in thread From: Andy Shevchenko @ 2017-07-24 9:22 UTC (permalink / raw) To: Arnd Bergmann Cc: Darren Hart, Andy Shevchenko, Platform Driver, linux-kernel@vger.kernel.org On Thu, Jul 20, 2017 at 7:00 PM, Arnd Bergmann <arnd@arndb.de> wrote: > 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. > Thanks, pushed to testing with slight change (+ empty lines after u8 zone; where it's applicable). I'm not going to move this to fixes queue since it looks to me not critical at all. Drop me a message if you think otherwise. > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483 > Link: https://patchwork.ozlabs.org/patch/788415/ > Suggested-by: Andy Shevchenko <andy@infradead.org> > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > v2: completely rewrite the patch after discussing with Andy > --- > drivers/platform/x86/alienware-wmi.c | 38 ++++++++++++++++++------------------ > 1 file changed, 19 insertions(+), 19 deletions(-) > > 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); > -- > 2.9.0 > -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning 2017-07-24 9:22 ` Andy Shevchenko @ 2017-07-25 7:23 ` Arnd Bergmann 0 siblings, 0 replies; 5+ messages in thread From: Arnd Bergmann @ 2017-07-25 7:23 UTC (permalink / raw) To: Andy Shevchenko Cc: Darren Hart, Andy Shevchenko, Platform Driver, linux-kernel@vger.kernel.org, gregkh On Mon, Jul 24, 2017 at 11:22 AM, Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Thu, Jul 20, 2017 at 7:00 PM, Arnd Bergmann <arnd@arndb.de> wrote: >> 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. >> > > Thanks, pushed to testing with slight change (+ empty lines after u8 > zone; where it's applicable). > I'm not going to move this to fixes queue since it looks to me not > critical at all. Drop me a message if you think otherwise. Sounds good, thanks! This instance is harmless, and the warning is now globally disabled in stable kernels (and in mainline). I plan to send a patch to re-enable the warning in mainline once all the other instances are addressed. I don't think that Greg will backport that patch, but if he does, then he may need some additional 30 patches besides this one. Arnd ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV 2017-07-20 16:00 [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Arnd Bergmann 2017-07-20 16:00 ` [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Arnd Bergmann @ 2017-07-21 0:02 ` Darren Hart 1 sibling, 0 replies; 5+ messages in thread From: Darren Hart @ 2017-07-21 0:02 UTC (permalink / raw) To: Arnd Bergmann Cc: Andy Shevchenko, Hans de Goede, platform-driver-x86, linux-kernel On Thu, Jul 20, 2017 at 06:00:50PM +0200, Arnd Bergmann wrote: > 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 <arnd@arndb.de> Queued to fixes branch for 4.13-rcX. I'll leave patch 2/2 to andy since you worked that one together already. -- Darren Hart VMware Open Source Technology Center ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-25 7:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-20 16:00 [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Arnd Bergmann 2017-07-20 16:00 ` [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Arnd Bergmann 2017-07-24 9:22 ` Andy Shevchenko 2017-07-25 7:23 ` Arnd Bergmann 2017-07-21 0:02 ` [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Darren Hart
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox