From patchwork Sat Oct 22 07:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1121178wrr; Sat, 22 Oct 2022 02:27:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Bs5ZOnKx9Ilw9iuJkW00CEe0u7csBxOLl0i+GqFg32bwN4S5g+pyGXcvTpxttf9yg/6nO X-Received: by 2002:a17:90a:c984:b0:20a:ac88:d39d with SMTP id w4-20020a17090ac98400b0020aac88d39dmr61976923pjt.13.1666430863976; Sat, 22 Oct 2022 02:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430863; cv=none; d=google.com; s=arc-20160816; b=X1hJPLPQqXhfs7MSAvl6kMbPwW0ScpGCbbLW63ehkMo1JM/+vYdxyO/LdoROeV2ssb q2Y7b0B/3Wdpe5dLCoWu3YYhGy/0EYDumVAzMdqf0hoqhzrS1MJMN0By/ABJUtWtJZS9 yHefC3odvS/ix4To1H3T1BWpkhW/yXmzCF596kuaFu4KmrgnkDfuEw+Qx0gs7F07obSn 6QvTitTszL/HHqiMthNx+KWku/uo2RmyD31V0dfPDh5rAgVCUgt3IYx+88WQXpfcRyxZ 07MOqAdU38uIFY97rptNcN0GOLLAdi26i9LWoQ8pYyiVCYLNFevFBHn02v9bBK1yy/Uu BSpQ== 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=MtTO+awmJYUVGkOcsGXAbRd+XU5yy2A35vP5wKJAP/TkrtE6zQDfIpdlxDjeWPlhQJ GQCX5Kh94PFEEoNA8I2Wi/+OCVi5nsdkdQkPpTQOkUWZpj7x+aJ689kowsjQVAM8mR9/ Awd/Mi9R7PrF2Xaq9iPw5gFtRPGjCuvvysfwDDj0/jKtxoPHaf0zjgFO4Rumk2T/te6f iGc6H0+NePbx2r1pNnuHxaJN7tu77K3B/16F/F5//w39S6HJGpAbK1nIT3P+ov+zi0vd /s0BPxIyyo88O5OPPDbaC7e+7jsmDT46SGzP1nKT9qLM9nZ08oc6p/RPqH8DynZ3v2Fm cNrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="X/WyWtuJ"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a170902cf0b00b0017f580f646fsi30918155plg.304.2022.10.22.02.27.32; Sat, 22 Oct 2022 02:27:43 -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="X/WyWtuJ"; 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 S234772AbiJVJDn (ORCPT + 99 others); Sat, 22 Oct 2022 05:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbiJVJCz (ORCPT ); Sat, 22 Oct 2022 05:02:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38562FA5D4; Sat, 22 Oct 2022 01:18:10 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B7E0660BB8; Sat, 22 Oct 2022 08:03:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADE0EC433D6; Sat, 22 Oct 2022 08:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425801; bh=k3ZzKbC9zNarUtRLUEgprjT0EFS8qIm+is5xwTEYpXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X/WyWtuJZlgKxqtVukjR7L1b9jq1tN5Zwvo2zlxXIZiGl9leGf7ogYJ0xNElu9Knm 1wkrreNWRRILqZqzXUlY8iYn1mNhWGZImz885AsRdVaaVVpCdWSsA8XLY64GtQZts+ ghFzZPx67KwW1ST2R1eA/GGPZD0qw2utjGYHOSvk= 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 5.19 591/717] hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms Date: Sat, 22 Oct 2022 09:27:50 +0200 Message-Id: <20221022072524.574695065@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747379409668291584?= X-GMAIL-MSGID: =?utf-8?q?1747379409668291584?= 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; }