From nobody Fri Oct 17 10:32:15 2025 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 00F14C43217 for ; Wed, 19 Oct 2022 11:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231961AbiJSLHj (ORCPT ); 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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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@9el= ements.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 =3D delay; + int time_remaining =3D delay; =20 while (time_remaining > 0) { _regulator_delay_helper(rdev->desc->poll_enabled_time); --=20 2.35.1