Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: set EV_ABS in dev->evbit even if input_alloc_absinfo() fails

The input core's error handling for input_alloc_absinfo() failures
is based on ignoring the error until input_register_device() runs
and then checks for the failure like this:

if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {
dev_err(&dev->dev, ...);
return -EINVAL;
}

This relies on EV_ABS actually getting set in dev->evbit even
if input_alloc_absinfo() fails, change input_set_abs_params() and
input_set_capability() to actually adhere to this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20220131143539.109142-1-hdegoede@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Hans de Goede and committed by
Dmitry Torokhov
3f9ed5c2 986c6f7c

+3 -6
+3 -6
drivers/input/input.c
··· 511 511 { 512 512 struct input_absinfo *absinfo; 513 513 514 + __set_bit(EV_ABS, dev->evbit); 515 + __set_bit(axis, dev->absbit); 516 + 514 517 input_alloc_absinfo(dev); 515 518 if (!dev->absinfo) 516 519 return; ··· 523 520 absinfo->maximum = max; 524 521 absinfo->fuzz = fuzz; 525 522 absinfo->flat = flat; 526 - 527 - __set_bit(EV_ABS, dev->evbit); 528 - __set_bit(axis, dev->absbit); 529 523 } 530 524 EXPORT_SYMBOL(input_set_abs_params); 531 525 ··· 2085 2085 2086 2086 case EV_ABS: 2087 2087 input_alloc_absinfo(dev); 2088 - if (!dev->absinfo) 2089 - return; 2090 - 2091 2088 __set_bit(code, dev->absbit); 2092 2089 break; 2093 2090