Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] avctp: Fix EINVAL on uinput creation
@ 2020-01-12  0:42 Haochen Tong
  2020-01-14  1:35 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Haochen Tong @ 2020-01-12  0:42 UTC (permalink / raw)
  To: linux-bluetooth

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: Haochen Tong <i@hexchain.org>
---
 profiles/audio/avctp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index d3b5dfab9..f7a3de211 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -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
-- 
2.24.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] avctp: Fix EINVAL on uinput creation
  2020-01-12  0:42 [PATCH] avctp: Fix EINVAL on uinput creation Haochen Tong
@ 2020-01-14  1:35 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2020-01-14  1:35 UTC (permalink / raw)
  To: i; +Cc: linux-bluetooth

Hi,

On Sat, Jan 11, 2020 at 4:49 PM Haochen Tong <i@hexchain.org> wrote:
>
> 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: Haochen Tong <i@hexchain.org>

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

> ---
>  profiles/audio/avctp.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
> index d3b5dfab9..f7a3de211 100644
> --- a/profiles/audio/avctp.c
> +++ b/profiles/audio/avctp.c
> @@ -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)

>         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.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-12  0:42 [PATCH] avctp: Fix EINVAL on uinput creation Haochen Tong
2020-01-14  1:35 ` Luiz Augusto von Dentz

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git