Skip to contentSkip to conversation

avctp: Fix EINVAL on uinput creation

PATCH Applied Haochen Tong 2 participants 2 messages Jan 12, 2020 – Jan 14, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 profiles/audio/avctp.c | 2 ++
 1 file changed, 2 insertions(+)
profiles/audio/avctp.c +2 -0
index d3b5dfab9..f7a3de211 100644
@@ -1182,6 +1182,8 @@ static int uinput_create(struct btd_device *device, const char *name,
 		}
 	}
 
+	memset(&dev, 0, sizeof(struct uinput_dev));
+
 	if (name) {
 		strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE);
 		dev.name[UINPUT_MAX_NAME_SIZE - 1] = '\0';

base-commit: b4270d79e19ee70ccab6c087a7b470dad8a8a8bf

Signature · 1 line
2.24.1
maintainer Applied
#1 lore raw

Hi,

Quoted 6 lines · Haochen Tong

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.

Ive the remove the line above since we don't use it for userspace patches, see HACKING.

profiles/audio/avctp.c static int uinput_create(struct btd_device *device, const char *name, · line 1185

Quoted 13 lines
---
 profiles/audio/avctp.c | 2 ++
 1 file changed, 2 insertions(+)
profiles/audio/avctp.c +1 -0
index d3b5dfab9..f7a3de211 100644
@@ -1182,6 +1182,8 @@ static int uinput_create(struct btd_device *device, const char *name,
                }
        }
 
+       memset(&dev, 0, sizeof(struct uinput_dev));

Ive change the above like to use sizeof(dev)

Quoted 7 lines
profiles/audio/avctp.c +0 -0
        if (name) {
                strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE);
                dev.name[UINPUT_MAX_NAME_SIZE - 1] = '\0';

base-commit: b4270d79e19ee70ccab6c087a7b470dad8a8a8bf --
2.24.1

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz