mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-21 23:57:36 -04:00
Input: maplemouse - fix NULL pointer dereference in open()
Commit555c765b0c("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:6b3480855a("maple: input: fix up maple mouse driver") Fixes:555c765b0c("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>
This commit is contained in:
committed by
Dmitry Torokhov
parent
d86d4f8cbb
commit
ee89db0042
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user