]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: maplemouse - fix NULL pointer dereference in open()
authorFlorian Fuchs <fuchsfl@gmail.com>
Tue, 30 Jun 2026 01:33:42 +0000 (18:33 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 30 Jun 2026 05:38:26 +0000 (22:38 -0700)
Commit 555c765b0cc2 ("Input: mouse - drop unnecessary calls to
input_set_drvdata") dropped the input_set_drvdata() call in probe
because the data appeared to be unused. However, dc_mouse_open() and
dc_mouse_close() were using maple_get_drvdata(to_maple_dev(&dev->dev)).
This appears to be accessing the data attached to an instance of
maple_device structure, while in reality this actually retrieves driver
data from the input device's embedded struct device (doing invalid
conversion of input device structure to maple device). After
input_set_drvdata() was removed, that lookup started returning NULL and
opening the input device dereferences mse->mdev.

Restore input_set_drvdata() and convert open() and close() to use
input_get_drvdata() so the dependency is no longer hidden.

Fixes: 6b3480855aad ("maple: input: fix up maple mouse driver")
Fixes: 555c765b0cc2 ("Input: mouse - drop unnecessary calls to input_set_drvdata")
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
Link: https://patch.msgid.link/20260628230715.2982552-1-fuchsfl@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/maplemouse.c

index c99f7e23421911f1cd0a91245636ab0592c70057..c41182766538aede2eb7821bd8bbe2fbf47ba467 100644 (file)
@@ -48,7 +48,7 @@ static void dc_mouse_callback(struct mapleq *mq)
 
 static int dc_mouse_open(struct input_dev *dev)
 {
-       struct dc_mouse *mse = maple_get_drvdata(to_maple_dev(&dev->dev));
+       struct dc_mouse *mse = input_get_drvdata(dev);
 
        maple_getcond_callback(mse->mdev, dc_mouse_callback, HZ/50,
                MAPLE_FUNC_MOUSE);
@@ -58,7 +58,7 @@ static int dc_mouse_open(struct input_dev *dev)
 
 static void dc_mouse_close(struct input_dev *dev)
 {
-       struct dc_mouse *mse = maple_get_drvdata(to_maple_dev(&dev->dev));
+       struct dc_mouse *mse = input_get_drvdata(dev);
 
        maple_getcond_callback(mse->mdev, dc_mouse_callback, 0,
                MAPLE_FUNC_MOUSE);
@@ -88,6 +88,7 @@ static int probe_maple_mouse(struct device *dev)
        mse->dev = input_dev;
        mse->mdev = mdev;
 
+       input_set_drvdata(input_dev, mse);
        input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
        input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
                BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE);