|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | #include <linux/acpi.h>
|
| 10 | +#include <linux/cleanup.h> |
10 | 11 | #include <linux/dmi.h>
|
11 | 12 | #include <linux/input.h>
|
12 | 13 | #include <linux/input/sparse-keymap.h>
|
13 | 14 | #include <linux/kernel.h>
|
14 | 15 | #include <linux/module.h>
|
| 16 | +#include <linux/mutex.h> |
15 | 17 | #include <linux/platform_device.h>
|
16 | 18 | #include <linux/suspend.h>
|
17 | 19 | #include "../dual_accel_detect.h"
|
@@ -66,6 +68,7 @@ static const struct key_entry intel_vbtn_switchmap[] = {
|
66 | 68 | };
|
67 | 69 |
|
68 | 70 | struct intel_vbtn_priv {
|
| 71 | + struct mutex mutex; /* Avoid notify_handler() racing with itself */ |
69 | 72 | struct input_dev *buttons_dev;
|
70 | 73 | struct input_dev *switches_dev;
|
71 | 74 | bool dual_accel;
|
@@ -155,6 +158,8 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
|
155 | 158 | bool autorelease;
|
156 | 159 | int ret;
|
157 | 160 |
|
| 161 | + guard(mutex)(&priv->mutex); |
| 162 | + |
158 | 163 | if ((ke = sparse_keymap_entry_from_scancode(priv->buttons_dev, event))) {
|
159 | 164 | if (!priv->has_buttons) {
|
160 | 165 | dev_warn(&device->dev, "Warning: received 0x%02x button event on a device without buttons, please report this.\n",
|
@@ -290,6 +295,10 @@ static int intel_vbtn_probe(struct platform_device *device)
|
290 | 295 | return -ENOMEM;
|
291 | 296 | dev_set_drvdata(&device->dev, priv);
|
292 | 297 |
|
| 298 | + err = devm_mutex_init(&device->dev, &priv->mutex); |
| 299 | + if (err) |
| 300 | + return err; |
| 301 | + |
293 | 302 | priv->dual_accel = dual_accel;
|
294 | 303 | priv->has_buttons = has_buttons;
|
295 | 304 | priv->has_switches = has_switches;
|
|
0 commit comments