Input: twl6040-vibra - fix NULL pointer dereference by removing workqueue
authorH. Nikolaus Schaller <hns@goldelico.com>
Mon, 18 Apr 2016 21:46:30 +0000 (14:46 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 19 Apr 2016 16:24:19 +0000 (09:24 -0700)
commit 21fb9f0d5e91 ("Input: twl6040-vibra - use system workqueue")

says that it switches to use the system workqueue but it did neither

- remove the workqueue struct variable
- replace code to really use the system workqueue

Instead it calls queue_work() on uninitialized info->workqueue.

The result is a NULL pointer dereference in vibra_play().

Solution: use schedule_work

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/twl6040-vibra.c

index ea63fad48de643be287648820c52bb7911771957..3a196ada689261cf42dff7a28cc6b5001cc92800 100644 (file)
@@ -45,7 +45,6 @@
 struct vibra_info {
        struct device *dev;
        struct input_dev *input_dev;
-       struct workqueue_struct *workqueue;
        struct work_struct play_work;
        struct mutex mutex;
        int irq;
@@ -213,7 +212,7 @@ static int vibra_play(struct input_dev *input, void *data,
        info->strong_speed = effect->u.rumble.strong_magnitude;
        info->direction = effect->direction < EFFECT_DIR_180_DEG ? 1 : -1;
 
-       ret = queue_work(info->workqueue, &info->play_work);
+       ret = schedule_work(&info->play_work);
        if (!ret) {
                dev_info(&input->dev, "work is already on queue\n");
                return ret;