From nobody Fri Dec 19 15:44:51 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 E8A39C38A2D for ; Mon, 24 Oct 2022 16:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233660AbiJXQ2a (ORCPT ); Mon, 24 Oct 2022 12:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233249AbiJXQ1f (ORCPT ); Mon, 24 Oct 2022 12:27:35 -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 43CE25FD3; Mon, 24 Oct 2022 08:14:27 -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 E71B3612BB; Mon, 24 Oct 2022 12:52:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 059F5C433C1; Mon, 24 Oct 2022 12:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615955; bh=zTri6CPQ9P0Lzgr20EKzelmjLoo2TzdJMIC0eulf4NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORsA4OK28Mf6SdydZ201u600qH6eRwDupXpp/xJpKjYs/zcTh6kXrbRrPyx5C1G3F kWME4OCNEXIKSmnggXYAKW+yPN6cczz6Ks8xMQC99gNXeOopFupUIgMcjVEpuUZNXl Vv4ylLaZ18XAv8vcxSwK+9BtYVTGyusP75jIl2po= 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 5.15 429/530] regulator: core: Prevent integer underflow Date: Mon, 24 Oct 2022 13:32:53 +0200 Message-Id: <20221024113104.508396489@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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 43613db7af75..aa4d78b02483 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2636,7 +2636,7 @@ static int _regulator_do_enable(struct regulator_dev = *rdev) * expired, 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_enable_delay(rdev->desc->poll_enabled_time); --=20 2.35.1