avctp: Fix EINVAL on uinput creation
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
@@ -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
Hi,
Quoted 6 lines · Haochen Tong
The struct
uinput_devvariable 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 Haochen Tong <[email protected]>
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@@ -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
-0if (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