Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3988428rwb; Sun, 9 Oct 2022 15:23:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZiGStKmpYEq4g1o+rxXZmYqs8Zgxgobayz9lr3xo89LdH8i62wdJ4dW8OSDQLqVe1dRIO X-Received: by 2002:a05:6402:350d:b0:45c:29d7:4f98 with SMTP id b13-20020a056402350d00b0045c29d74f98mr789612edd.40.1665354203421; Sun, 09 Oct 2022 15:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665354203; cv=none; d=google.com; s=arc-20160816; b=gZJEBursNMueMf0w1BAP1W/5gCqIVYkUOPsAVLlBbD0V5rFfXvNmrxUBerZ3WuSt7K wJqxQmUESsqrj0kLvvJk6UKM0Mp8hmbjrsXZXiy2nOeeZVjRzZNsXrjcBnvzDr1eVtY6 w8LQHy2iZlqhy8bmrvs68l9w3okvWCsYyy1CzAD+t858LET/mAerO0CqLKAiZxtgRqve y7Bc6Ivbwt7wffReA11juEyR5AwSrgrkGxJRqEBfMHwblxJQd51mfpg7xjrfodI/OKn4 3nswQAfFU4ptzLd1ljIxyYtkEvWzjr5lbLEIcWgRUxDP1MobbyGSvLLjfgC+5UJeRWUw 5k5A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QiO2hPOSoJY78FLN5Ya+tUojJQ3zH0W+VubGQib6/mY=; b=c9B0ncQiawppxrtsxBcsXaQ2rVOpC/+hrDra7pob9EhisG3SLV6/ISwwrnyK7soiiI qSwx+dz8JtPnlpSNMO2MOOOQF48a/8XXqQPPSDhwsV2nbgNNq9pKRL0pPZmX+W8r/Kcm Ers7yrvD3QQA0l7fRUwJm3y6I+o3bP9wxtrW841REBhrxtB2C5rvBjnKfRzGNJCY4faH 1DZBZ/P+jMwgsPC0MZAi4L1HGv6eZQLCtv9XYP0IizgVG/IfXiO+PTiy5GdDbWI2CBgY 6juAMSsZQXYo2ooFa95ITatev+pldhsECYKIQcuo9ubRd9sWk3fKoglTYv5iFZIK/XqW eS6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XD5e7jk3; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a056402139100b0045217702054si7607654edv.501.2022.10.09.15.22.56; Sun, 09 Oct 2022 15:23:23 -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=@kernel.org header.s=k20201202 header.b=XD5e7jk3; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbiJIWUg (ORCPT + 99 others); Sun, 9 Oct 2022 18:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231804AbiJIWTY (ORCPT ); Sun, 9 Oct 2022 18:19:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0AFF386B2; Sun, 9 Oct 2022 15:16:37 -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 7438060CEF; Sun, 9 Oct 2022 22:13:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23891C43470; Sun, 9 Oct 2022 22:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353590; bh=tGduk6NkYZkVJ9uF+cMq9hjrPTghwEt6RVgQ/f8m48Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XD5e7jk33bXizCI1D0oPg5rZU4XYGziYUVyaCwDy3VfT+Sdl7WZ2l4oXP8f4fbMGp v/Ug2oP75G7Xoa5wBRwMxRNPXo3d9th9w0xjSzWgn5WFHvqPmGqa1T7ZW/qqb8+wT1 PQFS9ZMlFKqe+lH1tQbyHymHYer/XfrR2D6imMXiv4svjZn81RjQZYQcHqQomhn5nV olPfMwdJDQUL2x9UjkGE8fyG5h7Hd1Ly0svo2IbDjoISXwmkK/sNkEg5hjRhF2s8qb QZAZMdkwdse1/kBIcMFWWZr8LtLaTyFe4mXv/4VRwq8zMLDP/IeUxWq8fAtr269Hpc PhsAhrJnDc/ow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Jason A. Donenfeld" , Guenter Roeck , Sasha Levin , jdelvare@suse.com, linux-hwmon@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 67/77] hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms Date: Sun, 9 Oct 2022 18:07:44 -0400 Message-Id: <20221009220754.1214186-67-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009220754.1214186-1-sashal@kernel.org> References: <20221009220754.1214186-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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