lkml.org 
[lkml]   [2019]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v1 3/3] cap11xx: fix potential user-after-free on module unload
Date
The work which is scheduled by led_classdev->brightness_set() is
potentially left pending or running until after the driver module
is unloaded.

Fix by using resource-controlled version of INIT_WORK().

Signed-off-by: Sven Van Asbroeck <TheSven73@googlemail.com>
---
drivers/input/keyboard/cap11xx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
index 312916f99597..a92dd8ee9ed7 100644
--- a/drivers/input/keyboard/cap11xx.c
+++ b/drivers/input/keyboard/cap11xx.c
@@ -312,7 +312,11 @@ static int cap11xx_init_leds(struct device *dev,
led->reg = reg;
led->priv = priv;

- INIT_WORK(&led->work, cap11xx_led_work);
+ error = devm_init_work(dev, &led->work, cap11xx_led_work);
+ if (error) {
+ of_node_put(child);
+ return error;
+ }

error = devm_led_classdev_register(dev, &led->cdev);
if (error) {
--
2.17.1
\
 
 \ /
  Last update: 2019-02-04 23:10    [W:0.077 / U:1.820 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site