Message ID | 20241211031150.2244639-1-make_ruc2021@163.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Input: Check dev_set_name() return value | expand |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index b5cbb57ee5f6..c4dc280c4c49 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -1361,7 +1361,9 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, /* Normalize device number if it falls into legacy range */ if (dev_no < EVDEV_MINOR_BASE + EVDEV_MINORS) dev_no -= EVDEV_MINOR_BASE; - dev_set_name(&evdev->dev, "event%d", dev_no); + error = dev_set_name(&evdev->dev, "event%d", dev_no); + if (error) + goto err_free_minor; evdev->handle.dev = input_get_device(dev); evdev->handle.name = dev_name(&evdev->dev);
It's possible that dev_set_name() returns -ENOMEM. We could catch and handle it by adding dev_set_name() return value check. Cc: stable@vger.kernel.org Fixes: 7f8d4cad1e4e ("Input: extend the number of event (and other) devices") Signed-off-by: Ma Ke <make_ruc2021@163.com> --- drivers/input/evdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)