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

Configure Feed

Select the types of activity you want to include in your feed.

Input: avoid calling input_set_abs_val() in the event handling core

input_abs_set_val() can nominally call input_alloc_absinfo() which may
allocate memory with GFP_KERNEL flag. This does not happen when
input_abs_set_val() is called by the input core to set current MT slot when
handling a new input event, but it trips certain static analyzers.

Rearrange the code to access the relevant structures directly.

Reported-by: Teng Qi <starmiku1207184332@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Link: https://lore.kernel.org/r/ZFBg379uuHjf+YEM@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+4 -2
+4 -2
drivers/input/input.c
··· 190 190 unsigned int code, int *pval) 191 191 { 192 192 struct input_mt *mt = dev->mt; 193 + bool is_new_slot = false; 193 194 bool is_mt_event; 194 195 int *pold; 195 196 ··· 211 210 pold = &dev->absinfo[code].value; 212 211 } else if (mt) { 213 212 pold = &mt->slots[mt->slot].abs[code - ABS_MT_FIRST]; 213 + is_new_slot = mt->slot != dev->absinfo[ABS_MT_SLOT].value; 214 214 } else { 215 215 /* 216 216 * Bypass filtering for multi-touch events when ··· 230 228 } 231 229 232 230 /* Flush pending "slot" event */ 233 - if (is_mt_event && mt && mt->slot != input_abs_get_val(dev, ABS_MT_SLOT)) { 234 - input_abs_set_val(dev, ABS_MT_SLOT, mt->slot); 231 + if (is_new_slot) { 232 + dev->absinfo[ABS_MT_SLOT].value = mt->slot; 235 233 return INPUT_PASS_TO_HANDLERS | INPUT_SLOT; 236 234 } 237 235