devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Jeff LaBundy <jeff@labundy.com>,
	dmitry.torokhov@gmail.com, robh+dt@kernel.org
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	jeff@labundy.com
Subject: Re: [PATCH v3 5/7] Input: iqs7222 - protect against undefined slider size
Date: Fri, 28 Oct 2022 10:15:58 +0200	[thread overview]
Message-ID: <87mt9gtlc1.fsf@baylibre.com> (raw)
In-Reply-To: <Y1SRXEi7XMlncDWk@nixie71>

On sam., oct. 22, 2022 at 19:57, Jeff LaBundy <jeff@labundy.com> wrote:

> Select variants of silicon do not define a default slider size, in
> which case the size must be specified in the device tree. If it is
> not, the axis's maximum value is reported as 65535 due to unsigned
> integer overflow.
>
> To solve this problem, move the existing zero-check outside of the
> conditional block that checks whether the property is present.
>
> Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
> Signed-off-by: Jeff LaBundy <jeff@labundy.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
> Changes in v3:
>  - None
>
> Changes in v2:
>  - Rebased to account for changes earlier in series
>
>  drivers/input/misc/iqs7222.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/misc/iqs7222.c b/drivers/input/misc/iqs7222.c
> index a5c08b1d9c9b..6af25dfd1d2a 100644
> --- a/drivers/input/misc/iqs7222.c
> +++ b/drivers/input/misc/iqs7222.c
> @@ -2024,7 +2024,7 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
>  
>  	error = fwnode_property_read_u32(sldr_node, "azoteq,slider-size", &val);
>  	if (!error) {
> -		if (!val || val > dev_desc->sldr_res) {
> +		if (val > dev_desc->sldr_res) {
>  			dev_err(&client->dev, "Invalid %s size: %u\n",
>  				fwnode_get_name(sldr_node), val);
>  			return -EINVAL;
> @@ -2043,6 +2043,13 @@ static int iqs7222_parse_sldr(struct iqs7222_private *iqs7222,
>  		return error;
>  	}
>  
> +	if (!(reg_offset ? sldr_setup[3]
> +			 : sldr_setup[2] & IQS7222_SLDR_SETUP_2_RES_MASK)) {
> +		dev_err(&client->dev, "Undefined %s size\n",
> +			fwnode_get_name(sldr_node));
> +		return -EINVAL;
> +	}
> +
>  	error = fwnode_property_read_u32(sldr_node, "azoteq,top-speed", &val);
>  	if (!error) {
>  		if (val > (reg_offset ? U16_MAX : U8_MAX * 4)) {
> -- 
> 2.34.1

      reply	other threads:[~2022-10-28  8:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-23  0:57 [PATCH v3 5/7] Input: iqs7222 - protect against undefined slider size Jeff LaBundy
2022-10-28  8:15 ` Mattijs Korpershoek [this message]

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=87mt9gtlc1.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jeff@labundy.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).