max7360_rotary->steps is only defaulted when reading the device-tree property "rotary-encoder,steps" fails. An explicit DT value of 0 makes the read succeed while leaving steps 0, and the event handler then does pos += steps % maxval; // maxval == steps == 0 pos = (pos + maxval) % maxval; i.e. a modulo by zero. Treat a zero result like a failed read and fall back to the default. Fixes: 229c15e9a69c ("input: misc: Add support for MAX7360 rotary") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- drivers/input/misc/max7360-rotary.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/max7360-rotary.c b/drivers/input/misc/max7360-rotary.c index d262931..ad7416c 100644 --- a/drivers/input/misc/max7360-rotary.c +++ b/drivers/input/misc/max7360-rotary.c @@ -127,7 +127,7 @@ static int max7360_rotary_probe(struct platform_device *pdev) error = device_property_read_u32(dev->parent, "rotary-encoder,steps", &max7360_rotary->steps); - if (error) + if (error || !max7360_rotary->steps) max7360_rotary->steps = MAX7360_ROTARY_DEFAULT_STEPS; device_property_read_u32(dev->parent, "rotary-debounce-delay-ms", -- 2.53.0