Skip to content

Commit d180b64

Browse files
Anastasia BelovaJiri Kosina
authored andcommitted
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: f31a2de ("HID: hid-lg4ff: Allow switching of Logitech gaming wheels between compatibility modes") Signed-off-by: Anastasia Belova <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 9ad6645 commit d180b64

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/hid/hid-lg4ff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,12 @@ static ssize_t lg4ff_alternate_modes_store(struct device *dev, struct device_att
872872
return -ENOMEM;
873873

874874
i = strlen(lbuf);
875+
876+
if (i == 0) {
877+
kfree(lbuf);
878+
return -EINVAL;
879+
}
880+
875881
if (lbuf[i-1] == '\n') {
876882
if (i == 1) {
877883
kfree(lbuf);

0 commit comments

Comments
 (0)