From patchwork Mon Oct 24 11:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp457883wru; Mon, 24 Oct 2022 06:36:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7b8BlHF0s/ePkIDq8iH5DEkFvp5o6c3hgYf75K1+agWp3wL7SddoOJf1yv3aKXzVtObveA X-Received: by 2002:a05:6402:2211:b0:461:5d0a:6678 with SMTP id cq17-20020a056402221100b004615d0a6678mr14455164edb.378.1666618600883; Mon, 24 Oct 2022 06:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618600; cv=none; d=google.com; s=arc-20160816; b=V1jZLC7Uqg1pu+eyMR5UU4ptOZ5h3sbRll/Af3i/woqSDHGCTQM5fxKVkNTZOpzlWw eebiTpU2AXDZI23MZBrMpGYvTJCziMfG9bH3YrkMRXucHn0UIaVgMCrePlPpdSsRb2v+ zApmTiRKFWwuBfmEiREsS2G+RtBU0DrigORX0e2SVUz5rT0EwSXRsltNfSvAGB3HXE0E /mVcWn86T3b5EpojFlHz8/gkTZQKakanfuSvz9t6TFPV9vz14mu3r7MWAIQjdEcJxLxy sNYr/FlzGZ4u5lEB4YAoHZ3sHZZmvw1eaI2x1SL1NLuwXkcPv+TJNHQ3NwioCeSjYVVW 8Unw== 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=mKKtrtuIDBSFWxGJ/Tuas3kdLnm85rYjf1NFp71KmC4=; b=n+6cC8qXFlrxoTSAPqYTydRLkI+8QoQegYPIKw6ib9njPcsAbT5YPsrCvkI8j1vfgh y12fugi/z3aE6EMTL3h6V17C93jlZfUP+1oc75b4nkNa4z67vo38kpqLanoZpSDoftUz s/eSMtGwZ+laMuNt2qLt9iO+cp2+hvbbOfv0VadPZSphbHNBMjpgt89EB98EI3MkT0gC 4UAGLhDI08hsb3MCLhE+XXbWrXyQoDcYEQ0lFlJwkKgvh0+4IDJAkdRtdvAAWgXkHOLS qtl3B+MO91kEbWgOzD55qcyKirHp80km/i2CyBeINrKk3dL9NWn9fg4F8dX3Sa42Gqvc LGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GKteBCsP; 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 hc33-20020a17090716a100b007a11c253eaasi7206694ejc.809.2022.10.24.06.35.57; Mon, 24 Oct 2022 06:36:40 -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=GKteBCsP; 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 S234286AbiJXN1j (ORCPT + 99 others); Mon, 24 Oct 2022 09:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236151AbiJXNYd (ORCPT ); Mon, 24 Oct 2022 09:24:33 -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 1D9E19F74D; Mon, 24 Oct 2022 05:30:45 -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 1603D61331; Mon, 24 Oct 2022 12:29:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27E6AC433C1; Mon, 24 Oct 2022 12:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614578; bh=wzVrqqZRg7fswRLItuLjYSP7Zzpk6JKxUzObx4VK59E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GKteBCsP0Zvgn7dIgWAQ8cY00GKpm4GHiukRQmtP98tqhu6Mp8XZBEVxXyShRriSc JJWa6WSn6Q+W4b/TxF4KSyYi4Hte0DyKXFF3FxjfSgtHH6ocsXR5DK/KwaRBJW73Q/ KkJF71Yeoz9k67RzZYMGvuYOX+vLupNd0D91hlRA= 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.10 313/390] regulator: core: Prevent integer underflow Date: Mon, 24 Oct 2022 13:31:50 +0200 Message-Id: <20221024113036.294889422@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747576265854318649?= X-GMAIL-MSGID: =?utf-8?q?1747576265854318649?= 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 317d701487ec..bf8ba73d6c7c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2544,7 +2544,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * expired, return -ETIMEDOUT. */ if (rdev->desc->poll_enabled_time) { - unsigned int time_remaining = delay; + int time_remaining = delay; while (time_remaining > 0) { _regulator_enable_delay(rdev->desc->poll_enabled_time);