Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1864644rwb; Fri, 19 Aug 2022 10:39:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4xz1HVD6BrTPQwib4rMyz+7w1W/BnS9MgtHMFMLlS+ZW5JuemBQb2B1iEuE4e+7XNSC5DH X-Received: by 2002:a17:907:75d9:b0:730:990f:6d6d with SMTP id jl25-20020a17090775d900b00730990f6d6dmr5528579ejc.638.1660930781613; Fri, 19 Aug 2022 10:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930781; cv=none; d=google.com; s=arc-20160816; b=AScnK1eoZgO/SAtaKIE+mJGVwwMNkHZBTcGQAx7x9yRLzBGLF33ZbiDcnFMVQLL0G5 YU4nFkuzmjVtsFW/gx/FEbnB6PQs5rkdkqIVMhBgy6+kN7T59lqzdhrmUp5N7CVSKBbg LSXtl5ejYnWpKXiD5VPkBprF+/MvnBrM34qU5bVhQeBwhT4j0t7g4Tl+LFzg4lVAq6dH 7pO/0lkAzUyhkuNkdrce1ojiUIfocAE5JDsbffmaaS+b2uD1Ccw0hyPK4cj/GkRp5tff 9pFzjMnVOLAkMFARsciZMIUPrasRE5gMdHSRbwLhNnb2y1wsUTg7MquonAixlavfPSWk 0Pfw== 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=A5cQIFo24aCS4MBdpF/jmQQfLnae8ZjgDlLLu4ifUDc=; b=DGbQaj/NbFY8QLkbPM2KKnNE1TXL/wcwxq5is4cKqpGHscjsPSn/Kj3CbKgrSqbroG wQ9EwwlyOgb+gZerUrQNEfX9Z/sLtg+vrHG96tw9MHHcGPNL32Q5bVwi/BFpX5pIgF+U jAjqbEvhRZC8cC3H4kOG9S9NNVdJJl/8qH73aVW1Z0ZuTZ2U+U+MedudJHntYf8QbrrR /BPw04NREL+3KYzYlZT1idiq295PifCeHV6QR9+PSnfx3kGcgaptTWm8v/JRTNGoMjtf QVz5yTd62t+97xV7vhYg4mnQd4Qc3c6kMAqBxgXw7OxcO4faje9+a+PERSinafXUT6Z/ JLKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZARfBAio; 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 gn17-20020a1709070d1100b007308550af97si4064368ejc.735.2022.08.19.10.39.15; Fri, 19 Aug 2022 10:39:41 -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=ZARfBAio; 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 S1351186AbiHSQDu (ORCPT + 99 others); Fri, 19 Aug 2022 12:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351291AbiHSQBO (ORCPT ); Fri, 19 Aug 2022 12:01:14 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CEF10A767; Fri, 19 Aug 2022 08:53:08 -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 50607CE26B6; Fri, 19 Aug 2022 15:52:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 413C3C433C1; Fri, 19 Aug 2022 15:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924356; bh=qVDrBSzVaPi+3Q9Qz4aFGHejuAGKOQ9q8ZjK5k3N9wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZARfBAiogdq/xuOKigGxSIN5VdO9je8I1Z2rDV9wuPp0ZaOhkU4Mu0G07M9zUCcW4 Zto6mhv78g1e4Ud9a7T/cLCJ0Jyi4VWla1V4XmCCyskqxkNt5mslt/+gsFJecNK09u KZYy/lkHm0gH15foppIkrVNvdpkOu0iU00x0GHGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Mark Brown , Sasha Levin Subject: [PATCH 5.10 143/545] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Fri, 19 Aug 2022 17:38:33 +0200 Message-Id: <20220819153835.726466630@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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.1 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,T_SCC_BODY_TEXT_LINE 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: Liang He [ Upstream commit 66efb665cd5ad69b27dca8571bf89fc6b9c628a4 ] We should call the of_node_put() for the reference returned by of_get_child_by_name() which has increased the refcount. Fixes: 40e20d68bb3f ("regulator: of: Add support for parsing regulator_state for suspend state") Signed-off-by: Liang He Link: https://lore.kernel.org/r/20220715111027.391032-1-windhl@126.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/of_regulator.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 06c0b15fe4c0..5d844697c7b6 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -206,8 +206,12 @@ static int of_get_regulation_constraints(struct device *dev, } suspend_np = of_get_child_by_name(np, regulator_states[i]); - if (!suspend_np || !suspend_state) + if (!suspend_np) continue; + if (!suspend_state) { + of_node_put(suspend_np); + continue; + } if (!of_property_read_u32(suspend_np, "regulator-mode", &pval)) { -- 2.35.1