Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60bce926 authored by Anastasia Belova's avatar Anastasia Belova Committed by Greg Kroah-Hartman
Browse files

HID: hid-lg4ff: Add check for empty lbuf



commit d180b6496143cd360c5d5f58ae4b9a8229c1f344 upstream.

If an empty buf is received, lbuf is also empty. So lbuf is
accessed by index -1.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: f31a2de3 ("HID: hid-lg4ff: Allow switching of Logitech gaming wheels between compatibility modes")
Signed-off-by: default avatarAnastasia Belova <abelova@astralinux.ru>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 625814b8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -872,6 +872,12 @@ static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_att
		return -ENOMEM;

	i = strlen(lbuf);

	if (i == 0) {
		kfree(lbuf);
		return -EINVAL;
	}

	if (lbuf[i-1] == '\n') {
		if (i == 1) {
			kfree(lbuf);