diff options
author | Anastasia Belova <abelova@astralinux.ru> | 2022-11-11 13:55:11 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-11-14 23:56:52 +0100 |
commit | d180b6496143cd360c5d5f58ae4b9a8229c1f344 (patch) | |
tree | c892b4806ab23ca0f5ff58d1a0c90450056101b6 /drivers/hid/hid-lg4ff.c | |
parent | HID: ite: Enable QUIRK_TOUCHPAD_ON_OFF_REPORT on Acer Aspire Switch V 10 (diff) | |
download | linux-d180b6496143cd360c5d5f58ae4b9a8229c1f344.tar.xz linux-d180b6496143cd360c5d5f58ae4b9a8229c1f344.zip |
HID: hid-lg4ff: Add check for empty lbuf
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: f31a2de3fe36 ("HID: hid-lg4ff: Allow switching of Logitech gaming wheels between compatibility modes")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-lg4ff.c')
-rw-r--r-- | drivers/hid/hid-lg4ff.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 5e6a0cef2a06..e3fcf1353fb3 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -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); |