summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-nintendo.c
diff options
context:
space:
mode:
authorClaudia Pellegrino <linux@cpellegrino.de>2021-11-14 05:53:27 +0300
committerJiri Kosina <jkosina@suse.cz>2021-11-19 17:54:31 +0300
commita1091118e0d6d84c2fdb94e6c397ac790bfb9dd6 (patch)
tree9f3f93d948edcac6eca7a968a4e66c07fae53acb /drivers/hid/hid-nintendo.c
parentfa48020c9fae2872f7bf8f38e09f73eb61fdb4ce (diff)
downloadlinux-a1091118e0d6d84c2fdb94e6c397ac790bfb9dd6.tar.xz
HID: magicmouse: prevent division by 0 on scroll
In hid_magicmouse, if the user has set scroll_speed to a value between 55 and 63 and scrolls seven times in quick succession, the step_hr variable in the magicmouse_emit_touch function becomes 0. That causes a division by zero further down in the function when it does `step_x_hr /= step_hr`. To reproduce, create `/etc/modprobe.d/hid_magicmouse.conf` with the following content: ``` options hid_magicmouse scroll_acceleration=1 scroll_speed=55 ``` Then reboot, connect a Magic Mouse and scroll seven times quickly. The system will freeze for a minute, and after that `dmesg` will confirm that a division by zero occurred. Enforce a minimum of 1 for the variable so the high resolution step count can never reach 0 even at maximum scroll acceleration. Fixes: d4b9f10a0eb6 ("HID: magicmouse: enable high-resolution scroll") Signed-off-by: Claudia Pellegrino <linux@cpellegrino.de> Tested-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-nintendo.c')
0 files changed, 0 insertions, 0 deletions