avctp: Fix EINVAL on uinput creation
authorHaochen Tong <i@hexchain.org>
Sun, 12 Jan 2020 00:42:26 +0000 (01:42 +0100)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:48 +0000 (14:30 +0530)
The struct uinput_dev variable is on stack, so clear its content to
avoid accidentally writing garbage values to kernel. This fixes "Can't
create uinput device: Invalid argument (22)" in some cases.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/avctp.c

index 66a4d93..8b731e7 100644 (file)
@@ -1240,6 +1240,8 @@ static int uinput_create(struct btd_device *device, const char *name,
                }
        }
 
+       memset(&dev, 0, sizeof(dev));
+
        if (name) {
                strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE);
                dev.name[UINPUT_MAX_NAME_SIZE - 1] = '\0';