Skip to content

Commit b52cbca

Browse files
jwrdegoedeij-intel
authored andcommitted
platform/x86: asus-wmi: Move i8042 filter install to shared asus-wmi code
asus-nb-wmi calls i8042_install_filter() in some cases, but it never calls i8042_remove_filter(). This means that a dangling pointer to the filter function is left after rmmod leading to crashes. Fix this by moving the i8042-filter installation to the shared asus-wmi code and also remove it from the shared code on driver unbind. Fixes: b564353 ("platform/x86: asus-wmi: Filter buggy scan codes on ASUS Q500A") Cc: Oleksij Rempel <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent a658471 commit b52cbca

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

drivers/platform/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ config ASUS_WMI
263263
depends on RFKILL || RFKILL = n
264264
depends on HOTPLUG_PCI
265265
depends on ACPI_VIDEO || ACPI_VIDEO = n
266+
depends on SERIO_I8042 || SERIO_I8042 = n
266267
select INPUT_SPARSEKMAP
267268
select LEDS_CLASS
268269
select NEW_LEDS
@@ -279,7 +280,6 @@ config ASUS_WMI
279280
config ASUS_NB_WMI
280281
tristate "Asus Notebook WMI Driver"
281282
depends on ASUS_WMI
282-
depends on SERIO_I8042 || SERIO_I8042 = n
283283
help
284284
This is a driver for newer Asus notebooks. It adds extra features
285285
like wireless radio and bluetooth control, leds, hotkeys, backlight...

drivers/platform/x86/asus-nb-wmi.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ static const struct dmi_system_id asus_quirks[] = {
503503

504504
static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
505505
{
506-
int ret;
507-
508506
quirks = &quirk_asus_unknown;
509507
dmi_check_system(asus_quirks);
510508

@@ -519,15 +517,6 @@ static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
519517

520518
if (tablet_mode_sw != -1)
521519
quirks->tablet_switch_mode = tablet_mode_sw;
522-
523-
if (quirks->i8042_filter) {
524-
ret = i8042_install_filter(quirks->i8042_filter);
525-
if (ret) {
526-
pr_warn("Unable to install key filter\n");
527-
return;
528-
}
529-
pr_info("Using i8042 filter function for receiving events\n");
530-
}
531520
}
532521

533522
static const struct key_entry asus_nb_wmi_keymap[] = {

drivers/platform/x86/asus-wmi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,6 +4567,12 @@ static int asus_wmi_add(struct platform_device *pdev)
45674567
goto fail_wmi_handler;
45684568
}
45694569

4570+
if (asus->driver->quirks->i8042_filter) {
4571+
err = i8042_install_filter(asus->driver->quirks->i8042_filter);
4572+
if (err)
4573+
pr_warn("Unable to install key filter - %d\n", err);
4574+
}
4575+
45704576
asus_wmi_battery_init(asus);
45714577

45724578
asus_wmi_debugfs_init(asus);
@@ -4603,6 +4609,8 @@ static int asus_wmi_remove(struct platform_device *device)
46034609
struct asus_wmi *asus;
46044610

46054611
asus = platform_get_drvdata(device);
4612+
if (asus->driver->quirks->i8042_filter)
4613+
i8042_remove_filter(asus->driver->quirks->i8042_filter);
46064614
wmi_remove_notify_handler(asus->driver->event_guid);
46074615
asus_wmi_backlight_exit(asus);
46084616
asus_screenpad_exit(asus);

0 commit comments

Comments
 (0)