mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 07:34:06 +08:00
Input: uinput - fix setting up device name
The check for non-empty device name was botched since we tried to account for extra space for the terminating zero at the same time. Convert to kstrndup() to avoid this problem. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Aristeu Rozanski <aris@ruivo.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
26cdb1ae76
commit
5d9d6e91b8
@ -347,8 +347,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
|
|||||||
{
|
{
|
||||||
struct uinput_user_dev *user_dev;
|
struct uinput_user_dev *user_dev;
|
||||||
struct input_dev *dev;
|
struct input_dev *dev;
|
||||||
char *name;
|
int i;
|
||||||
int i, size;
|
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (count != sizeof(struct uinput_user_dev))
|
if (count != sizeof(struct uinput_user_dev))
|
||||||
@ -373,19 +372,19 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
|
|||||||
|
|
||||||
udev->ff_effects_max = user_dev->ff_effects_max;
|
udev->ff_effects_max = user_dev->ff_effects_max;
|
||||||
|
|
||||||
size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
|
/* Ensure name is filled in */
|
||||||
if (!size) {
|
if (!user_dev->name[0]) {
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(dev->name);
|
kfree(dev->name);
|
||||||
dev->name = name = kmalloc(size, GFP_KERNEL);
|
dev->name = kstrndup(user_dev->name, UINPUT_MAX_NAME_SIZE,
|
||||||
if (!name) {
|
GFP_KERNEL);
|
||||||
|
if (!dev->name) {
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
strlcpy(name, user_dev->name, size);
|
|
||||||
|
|
||||||
dev->id.bustype = user_dev->id.bustype;
|
dev->id.bustype = user_dev->id.bustype;
|
||||||
dev->id.vendor = user_dev->id.vendor;
|
dev->id.vendor = user_dev->id.vendor;
|
||||||
|
Loading…
Reference in New Issue
Block a user