From dcf3cdda583707ecb797fefc45f8cccb09d2d8ce Mon Sep 17 00:00:00 2001 From: Haochen Tong Date: Sun, 12 Jan 2020 01:42:26 +0100 Subject: [PATCH] avctp: Fix EINVAL on uinput creation 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 Signed-off-by: Ayush Garg --- profiles/audio/avctp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index 66a4d93..8b731e7 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -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'; -- 2.7.4