All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Shirong Zhao <shxzhaosr@163.com>, Rob Herring <robh@kernel.org>
Cc: linux-input@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] Input: rotary_encoder - default steps to 24 to avoid divide by zero
Date: Sat, 5 Dec 2026 20:36:26 -0800	[thread overview]
Message-ID: <axTj7m91WwwDSFFr@google.com> (raw)
In-Reply-To: <20261205112855.18-1-shxzhaosr@163.com>

Hi Shirong,

On Sat, Dec 05, 2026 at 07:28:55PM +0800, Shirong Zhao wrote:
> The driver reads the device-tree property "rotary-encoder,steps" but
> ignores the return value and applies no default.  If the property is
> absent (or explicitly 0), steps stays 0 after the kzalloc'd structure is
> filled, and the IRQ handler does
> 
> 	if (encoder->rollover)
> 		pos %= encoder->steps;
> 
> i.e. a modulo by zero when "rotary-encoder,rollover" is set.  The binding
> documented a default of 24; honour it and also treat a failing read as
> using the default.

I can see using the default if the schema says its an optional property,
but if somebody trues to specify 0 why not reject it?

> 
> Fixes: 80c99bcd2861 ("Input: rotary-encoder - add DT bindings")
> Cc: stable@vger.kernel.org

In any case, I do not see the reason for this to be in stable. DT data
it is not an untrusted input.

I really am not sure how much we want to validate in kernel vs relying
on schema validation. Rob, anything from your side?

Thanks.

-- 
Dmitry

  reply	other threads:[~2026-12-06  4:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 11:28 [PATCH] Input: rotary_encoder - default steps to 24 to avoid divide by zero Shirong Zhao
2026-12-06  4:36 ` Dmitry Torokhov [this message]
2026-12-06  4:43 ` [PATCH v2] Input: rotary-encoder - honour the documented default step count Shirong Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axTj7m91WwwDSFFr@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=shxzhaosr@163.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.