From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22C2CC38A02 for ; Fri, 28 Oct 2022 08:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbiJ1IQC (ORCPT ); Fri, 28 Oct 2022 04:16:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbiJ1IQC (ORCPT ); Fri, 28 Oct 2022 04:16:02 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0279719E029 for ; Fri, 28 Oct 2022 01:16:01 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id r186-20020a1c44c3000000b003cf4d389c41so3100462wma.3 for ; Fri, 28 Oct 2022 01:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=nNUdT0pPy3cOwelmgfn8Li0duY7pG3zcPFGqUcnDR0I=; b=cL7qGw+WZ7oIhsoKvAp/fncO/Powx/3R0gYRYrHXfBqCZMARA06h55UJpiBp1VS/M5 ckkZFgxPpA1zetD0U8Z3+0E3iH/cM4OqfSddJpjlZwTArXB12hDevrLav4PrYt94mdoi H2ywL/n6XnQMdOSDC1BH0uvMi5or7vSikzSAjHZ6WYJWrdc1oA19sktR4yGDlphGweFy qa7chU3YL1Zmq/bjuHqNXhzdtiWBJpo53xE1JScUdrlh2Y+fChB6MS8ujMh60OCL1Zo9 NF8h/EfkGO5DT1ZZQHvPR4nmx20JrET8RJgTTEEfcvVYWINDC7x2U4iZYHy9nnoHa5y4 OJQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nNUdT0pPy3cOwelmgfn8Li0duY7pG3zcPFGqUcnDR0I=; b=IHO7G3w7S7vdUxbIWIienin+0D+FOM6sZYSOgC8ckz9ez7jrypykURLUUQiiXtvJ2K /EXI9m4U/lowR36SVSndp2wVjADCjT4ArPNEWt1eMHBtiA4jrYQicnsLtv1zOXJ5yWdY LlXejN2CKxT6DDVIrp7QtQ2u50v5xWd3Z8uaTAOk75ertiI1zz/kHc+jnYuOcBfTRW1v Pae+KEvNmWE3QCeDrKlJZs9LLlbsZAcrtdj3/3k31r4zX8PvhdPRVDDhX02CafJ/jAae URsYChWRh9AjajcrDYRq08jq2uoshJwYhIcjhBxwf86qt0+PKsGIH517jNiFJj6clqhs PfLw== X-Gm-Message-State: ACrzQf2npDNNsGlMGCYV/McrroEzwwhr7OUxv5+PI7NX3TOSqXHoaysd zHTnBm0/766u5Yll4+rSm7dzCg== X-Google-Smtp-Source: AMsMyM5OHXihJsfaY0g3uCEzw4Qk3wyZTMnWLQXTWhLkH4yx/A61d//fGaZJsClTjAWBlUuLbuLXPA== X-Received: by 2002:a05:600c:4f86:b0:3cc:e010:7a7b with SMTP id n6-20020a05600c4f8600b003cce0107a7bmr8699332wmq.114.1666944959478; Fri, 28 Oct 2022 01:15:59 -0700 (PDT) Received: from localhost ([2a01:cb19:85e6:1900:98b2:dc79:fe90:6dad]) by smtp.gmail.com with ESMTPSA id bk17-20020a0560001d9100b0022cdb687bf9sm3974247wrb.0.2022.10.28.01.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 01:15:59 -0700 (PDT) From: Mattijs Korpershoek To: Jeff LaBundy , 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 In-Reply-To: References: Date: Fri, 28 Oct 2022 10:15:58 +0200 Message-ID: <87mt9gtlc1.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On sam., oct. 22, 2022 at 19:57, Jeff LaBundy 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 Reviewed-by: Mattijs Korpershoek > --- > 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