Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp906034rwi; Wed, 19 Oct 2022 04:35:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Qo3R7Lvbdj3u9Hya3jzgRqGiPAVuvTLEgN9pBNDfr8aYesGBgC8Dbg0jitXN/bat4gWav X-Received: by 2002:a63:e22:0:b0:458:cfe7:958 with SMTP id d34-20020a630e22000000b00458cfe70958mr6746392pgl.449.1666179301405; Wed, 19 Oct 2022 04:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179301; cv=none; d=google.com; s=arc-20160816; b=gQSPA0T3tq7SCMTOLkYiKqdDRTOEOR+BldtLVHcpR+BL3wLG+HXLhxpEfkQ3MGHXs9 5ahKzPbTIUSt7SWhKdlL2UomK5iHXQhSmDIfX96UpCDozsVmDLcinhsEc47IR+pM7C6A e8FU1i5efrwUUGahKxnb/8XSUy00KO27JrJRd6mZ06wg9GB7skgWhrRjdq7o4VIvcqxx uZo9uzepRKyBzMrgsFo7n5yK6pEXo8WiXW2kTlCHXovzbBM5BK4+ExJF+W3vOZAAXsgF ZCkTah2oVsIZMPckH0XtZ8jLERsUr2q9hKmu18oQLoExIO2JOL0+Z2l0/Qnf36NDYDfK AiUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wdSy2AMLBHsR0r0O87E+S3p7TRRvKcKur5NO1csm2CM=; b=iPmp7iu5QG0P21ZhqDbuw6aa4SnU+dbQT2azBjkQv/8ttK6NVCh027/y/YLcVz19WM YLUDrW3bqHYrbpWlBnffOzIxLHaPNEaYWk0NmiXU3JpgBwNC4oN5vvUcBHNROUDMOrnE dXNEtwdNsOF4Mg706DedcrC+QVh04sos9nIW0mLbAm4WMs7YaJBxaMC+Dg3+G4H2+3Mv iVW2qfkNpnDjtvARpV8RVo3On8rCpSgAoRHxqG6rNSBbuGfImQd0zC3awnpMt+3y1t5B DgKxZC7b0csqUdXEwfrOOB8Xzeq8ev/8Ckwdubz4GMGg/tqinojkRFR05n/Px84eHjho UvHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vko1kLCk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a056a0022c200b005633766252asi21018645pfj.313.2022.10.19.04.34.50; Wed, 19 Oct 2022 04:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vko1kLCk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234792AbiJSK5k (ORCPT + 99 others); Wed, 19 Oct 2022 06:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234548AbiJSK4b (ORCPT ); Wed, 19 Oct 2022 06:56:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C03FE15708; Wed, 19 Oct 2022 03:27:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1A5DDB824B1; Wed, 19 Oct 2022 09:10:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BE4EC433D6; Wed, 19 Oct 2022 09:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170605; bh=k3ZzKbC9zNarUtRLUEgprjT0EFS8qIm+is5xwTEYpXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vko1kLCkPNpA4L/G7nh2Mv51uAkqP+FOU7pbc1Pr6BGSiTaDWduVLWhXSEBtxVuPa 7ox0QSeHURnfdYPs77do1nHIAPwDeXtCCKqMEB+D1+euUrf+Cc049ppW6e5luGZsFZ oZuiBaB37jB//A52rkwJA3vmv+M2ZOU8jfRXRQoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" , Guenter Roeck , Sasha Levin Subject: [PATCH 6.0 719/862] hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms Date: Wed, 19 Oct 2022 10:33:26 +0200 Message-Id: <20221019083321.710685275@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason A. Donenfeld [ Upstream commit f9c0cf8f26de367c58e48b02b1cdb9c377626e6f ] On 32-bit platforms, long is 32 bits, so (long)UINT_MAX is less than (long)SHT4X_MIN_POLL_INTERVAL, which means the clamping operation is bogus. Fix this by clamping at INT_MAX, so that the upperbound is the same on all platforms. Signed-off-by: Jason A. Donenfeld Link: https://lore.kernel.org/r/20220924101151.4168414-1-Jason@zx2c4.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/sht4x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c index c19df3ade48e..13ac2d8f22c7 100644 --- a/drivers/hwmon/sht4x.c +++ b/drivers/hwmon/sht4x.c @@ -129,7 +129,7 @@ static int sht4x_read_values(struct sht4x_data *data) static ssize_t sht4x_interval_write(struct sht4x_data *data, long val) { - data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, UINT_MAX); + data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, INT_MAX); return 0; } -- 2.35.1