Skip to content

Commit 97d5c8f

Browse files
LawstorantJiri Kosina
authored andcommitted
HID: pidff: Fix condition effect bit clearing
As reported by MPDarkGuy on discord, NULL pointer dereferences were happening because not all the conditional effects bits were cleared. Properly clear all conditional effect bits from ffbit Fixes: 7f3d7bc ("HID: pidff: Better quirk assigment when searching for fields") Cc: stable@vger.kernel.org # 6.18.x Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent ecfa6f3 commit 97d5c8f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/hid/usbhid/hid-pidff.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,10 +1452,13 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
14521452
hid_warn(pidff->hid, "unknown ramp effect layout\n");
14531453

14541454
if (PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) {
1455-
if (test_and_clear_bit(FF_SPRING, dev->ffbit) ||
1456-
test_and_clear_bit(FF_DAMPER, dev->ffbit) ||
1457-
test_and_clear_bit(FF_FRICTION, dev->ffbit) ||
1458-
test_and_clear_bit(FF_INERTIA, dev->ffbit))
1455+
bool test = false;
1456+
1457+
test |= test_and_clear_bit(FF_SPRING, dev->ffbit);
1458+
test |= test_and_clear_bit(FF_DAMPER, dev->ffbit);
1459+
test |= test_and_clear_bit(FF_FRICTION, dev->ffbit);
1460+
test |= test_and_clear_bit(FF_INERTIA, dev->ffbit);
1461+
if (test)
14591462
hid_warn(pidff->hid, "unknown condition effect layout\n");
14601463
}
14611464

0 commit comments

Comments
 (0)