Skip to contentSkip to conversation

Input: exc3000 - properly stop timer on shutdown

PATCH In review Dmitry Torokhov 2 participants 2 messages Jan 30, 2023

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: exc3000 - properly stop timer on shutdown

We need to stop the timer on driver unbind or probe failures, otherwise we get UAF/Oops.

Fixes 7e577a17f2ee ("Input: add I2C attached EETI EXC3000 multi touch driver")
---
 drivers/input/touchscreen/exc3000.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/input/touchscreen/exc3000.c +10 -0
index 4b7eee01c6aa..69eae79e2087 100644
@@ -109,6 +109,11 @@ static inline void exc3000_schedule_timer(struct exc3000_data *data)
 	mod_timer(&data->timer, jiffies + msecs_to_jiffies(EXC3000_TIMEOUT_MS));
 }
 
+static void exc3000_shutdown_timer(void *timer)
+{
+	timer_shutdown_sync(timer);
+}
+
 static int exc3000_read_frame(struct exc3000_data *data, u8 *buf)
 {
 	struct i2c_client *client = data->client;
@@ -386,6 +391,11 @@ static int exc3000_probe(struct i2c_client *client)
 	if (error)
 		return error;
 
+	error = devm_add_action_or_reset(&client->dev, exc3000_shutdown_timer,
+					 &data->timer);
+	if (error)
+		return error;
+
 	error = devm_request_threaded_irq(&client->dev, client->irq,
 					  NULL, exc3000_interrupt, IRQF_ONESHOT,
 					  client->name, data);
Signature · 5 lines
2.39.1.456.gfc5497dd1b-goog


-- 
Dmitry
#1 lore raw
Quoted 38 lines · Dmitry Torokhov

We need to stop the timer on driver unbind or probe failures, otherwise
we get UAF/Oops.

Fixes 7e577a17f2ee ("Input: add I2C attached EETI EXC3000 multi

touch driver")

---
 drivers/input/touchscreen/exc3000.c | 10 ++++++++++

 1 file changed, 10 insertions(+)
drivers/input/touchscreen/exc3000.c +0 -0
index 4b7eee01c6aa..69eae79e2087 100644
@@ -109,6 +109,11 @@ static inline void exc3000_schedule_timer(struct
 exc3000_data *data)

        mod_timer(&data->timer, jiffies +
msecs_to_jiffies(EXC3000_TIMEOUT_MS));
 }

drivers/input/touchscreen/exc3000.c +5 -0
+static void exc3000_shutdown_timer(void *timer)
+{
+       timer_shutdown_sync(timer);
+}
+

 static int exc3000_read_frame(struct exc3000_data *data, u8 *buf) {
        struct i2c_client *client = data->client;

drivers/input/touchscreen/exc3000.c +0 -0
@@ -386,6 +391,11 @@ static int exc3000_probe(struct i2c_client
 *client)
         if (error)
                 return error;


+       error = devm_add_action_or_reset(&client->dev, exc3000_shutdown_timer,

Quoted 12 lines

+                                        &data->timer);
+       if (error)
+               return error;
+
        error = devm_request_threaded_irq(&client->dev, client->irq, NULL, exc3000_interrupt, IRQF_ONESHOT,
                                          client->name, data);

Signature · 1 line
2.39.1.456.gfc5497dd1b-goog

This should probably be Cc'ed to the stable mailing list.

Signature · 1 line
~miko