Skip to content

Commit ef0e669

Browse files
LawstorantSasha Levin
authored andcommitted
HID: pidff: Fix condition effect bit clearing
commit 97d5c8f upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 575122c commit ef0e669

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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)