From patchwork Sat Oct 22 07:27:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7856 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1160914wrr; Sat, 22 Oct 2022 04:29:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68a6FGRSKj9fzPBLB0HMLbBZeUgnAOBo7ArejplQNHL9HOpkS1yzH3cv17ARAUZd3ACeCB X-Received: by 2002:a17:903:22c1:b0:185:5276:92e5 with SMTP id y1-20020a17090322c100b00185527692e5mr23885549plg.134.1666438140800; Sat, 22 Oct 2022 04:29:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666438140; cv=none; d=google.com; s=arc-20160816; b=C5szln619uWr9L9iiie42MlvdCP9UbRubtyKk2W31h6533W/EaPyINAJsVWtPGykWw +1i+Vd+wNvGr0cqy/bmOAaNGud0wGOYWmOjElZRPm5lFkeQlQvDaGyI1aJJuj6MBItTT e1HWuwVRaHJ0YeIJAan4lmnwutY0hE/6MJfSdYQXv0U5aePR3y27tPSeq8JxUg7bxISG /CBsJ+RDljkEnhlHACzQp7JdjqK9Z4swL1R2B/p2ST0745tKPDFGb5PwABWMHbSN/Z9Q mJTzv1uA7Zs6AtWhY+uuLipuJ1UToKLKc86jLtmIj3NFA341sNdKxxFL8/X0oE/qP9ts VTCw== 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=MS1/oJx9VSDkkg70x51KWEtO7x7lndaVvIDnXsbp9s0=; b=BNqVANOAPYOwEE0Pi6BYpq89p52xE2h1Seoip9AGfqDfyjGZwhj+CzFLHjhND24pn0 ntCYBSyOYpETHNPOMj3qLbRiIgsvKstDcQ8kVzNG9J92Fhw6qSWFNMB8LYt8ka/YlBVM sJLDwj8IH17Hv6d83WYZvzIbEVq/qIfwaMP30BPv8phsWVUpcGkyagx8w/af/4mzDJHq 5nF3cmWa3EKep9LGJl/niMmmJZSVdbImLLTXCgMMFPxuu2LeY3wxyyd3h+ddyJgMtSQu ruazLVDGcqeT5MYMvsFRPVv3i+CFRWrItE90rj3gc+tpC++QiXZMUMK5q2I9UojkEiRe XZkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sSz62sX6; 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 cj11-20020a056a00298b00b005567d823a2esi27701541pfb.306.2022.10.22.04.28.43; Sat, 22 Oct 2022 04:29:00 -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=sSz62sX6; 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 S229718AbiJVLTU (ORCPT + 99 others); Sat, 22 Oct 2022 07:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiJVLTC (ORCPT ); Sat, 22 Oct 2022 07:19:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D45FB516C; Sat, 22 Oct 2022 03:46:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7DFF8B82E2C; Sat, 22 Oct 2022 08:01:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAA16C433C1; Sat, 22 Oct 2022 08:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425668; bh=e69ynLJuqC7qhUEJrETi/PJwrTuWrNPBE7bGAuEbq7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sSz62sX6eCNAVniiwmRxvv2bQcUDIatY+XHNYm6eBOVV+JZs/ypMetdahk61ebO3e 1ufptsi33eZPJqxdy4Ahcz4b4lpI6OTj1QWACt0dU4wvxrizCf7mi9m5sJFwZNMIUi P8wrELy1giJM77thWsMYMK7kZENDlFATxfeZ8Flo= 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.19 576/717] regulator: core: Prevent integer underflow Date: Sat, 22 Oct 2022 09:27:35 +0200 Message-Id: <20221022072523.902013293@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.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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747387040055717093?= X-GMAIL-MSGID: =?utf-8?q?1747387040055717093?= 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 a9daaf4d5aaa..9567d2fc3f00 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2680,7 +2680,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);