Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp907891rwi; Wed, 19 Oct 2022 04:36:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hg86h8ua6UL3Di66YSopdxRD0WsmRzGjaC/T/hF9gzwyAduIsfDcFmygWqD8QFAgnCEcl X-Received: by 2002:a05:6a00:acb:b0:555:ac02:433e with SMTP id c11-20020a056a000acb00b00555ac02433emr8216072pfl.3.1666179387224; Wed, 19 Oct 2022 04:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666179387; cv=none; d=google.com; s=arc-20160816; b=0I7teTNWV+wuG0hy659GJr2YBkALTT9oaSFG/sVRTWmr9FZILAV0y8oh0LuOXiO4eI h5TXOvla1MF7Q+Tr8wN3eq85d/tfyNfknS3kKNsigluuFZXaECX8tyS5KWJNQ1RZasMy EfqdQfym3uSfN+gP/5f/gu58HKCYwYa6LoJs94RPuvyvw3KyaFVPSFrp75HltWxzAsUR 6rO2GHzf6frtSAoFNpBRpldN3fVuCGt5aHz/Pk6Wjh8gC6Mmv5mKslwFnDKoLl+pS9Kv zko8Kk9pz5J4fNfKhDQXeF6i5V0Z5OkkK+Yuw8Tvu/Wkzwpg3BnBIKr6HHJTm5swbFKv xVqg== 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=j54LxoE0bbC3aDOjIHAmzD1Sy1EUsR1wlh666B/z1+U=; b=aURLPsewIacieFtrRQPk3BWXNVJ55znultmfDv0p8UNKpMPZFzaHdYuY+Or5r48lhW ocv6mfrcpPFwmkjTMNZImI2//QcEh4Pjpe0XQpd7JbLnnpbkb3Qm2kE8ByxcTHA7nW6z wRrCidqhnDJ7PaXp+8VS7b1mgpTUh8MfCCt6I/s5VM64QDYnmLFXQMkty8umfXkh8KmQ LqwnBF8YcCRWLM6p0lZ2FnubxtUeM/iY7k8Ajbily/oPFfIYZukzl/iXMKuamjRzvbox JdvFzO5dYiB9Qdi9zKEjas+Bd3c+99xto2Y05VCj3FAMLI94CQGTf2ayrFOaL4iHHZ8L nKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jwgSrylH; 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 g22-20020a63f416000000b004350783ee63si17872681pgi.237.2022.10.19.04.36.13; Wed, 19 Oct 2022 04:36:27 -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=jwgSrylH; 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 S230134AbiJSLHj (ORCPT + 99 others); Wed, 19 Oct 2022 07:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234008AbiJSLHH (ORCPT ); Wed, 19 Oct 2022 07:07:07 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05A22408C; Wed, 19 Oct 2022 03:36:09 -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 sin.source.kernel.org (Postfix) with ESMTPS id E2C96CE218C; Wed, 19 Oct 2022 09:09:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A739C433D7; Wed, 19 Oct 2022 09:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170569; bh=7+9iLh8rQ4HHyOSIN1Pqo+gNYTzhMkFpZiwMptBxaMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jwgSrylHOCjnvrOQyAz1pPLxeG38w2vNao7DZFkvyjCzotsyt+AbfXRFq5HTgl4FE 9VdOY9NsR1xEYRkTSn6kqnd6H00crRA8pRpjPsIK6+bdw2b4KYRWC+FoAjFGcbvwSe E31jyBc7FOu+D7Hmjjgd61LszShUjbMlFuFQ3kQ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrick Rudolph , Mark Brown , Sasha Levin Subject: [PATCH 6.0 703/862] regulator: core: Prevent integer underflow Date: Wed, 19 Oct 2022 10:33:10 +0200 Message-Id: <20221019083321.051979568@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: Patrick Rudolph [ Upstream commit 8d8e16592022c9650df8aedfe6552ed478d7135b ] By using a ratio of delay to poll_enabled_time that is not integer time_remaining underflows and does not exit the loop as expected. As delay could be derived from DT and poll_enabled_time is defined in the driver this can easily happen. Use a signed iterator to make sure that the loop exits once the remaining time is negative. Signed-off-by: Patrick Rudolph Link: https://lore.kernel.org/r/20220909125954.577669-1-patrick.rudolph@9elements.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d3e8dc32832d..c3871565fd7d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2681,7 +2681,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * return -ETIMEDOUT. */ if (rdev->desc->poll_enabled_time) { - unsigned int time_remaining = delay; + int time_remaining = delay; while (time_remaining > 0) { _regulator_delay_helper(rdev->desc->poll_enabled_time); -- 2.35.1