Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3413550rwa; Tue, 23 Aug 2022 04:29:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6N7NSjoBVQzZf+dgKWrJWAv8pjB29VJwwAC774Hja0bXZJySwqMCE3R95dRzhnvUGHb3sX X-Received: by 2002:a63:4b4a:0:b0:427:bbb0:110e with SMTP id k10-20020a634b4a000000b00427bbb0110emr20353847pgl.397.1661254189256; Tue, 23 Aug 2022 04:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254189; cv=none; d=google.com; s=arc-20160816; b=dmdEqylVxFP0kLWL1SVfDppKjm6HmD1VJ7Qd0aU7UlXouRQQjN6fQIgqXICAYZNeeP HjRPFUX7c4DfdEI/IywyDXIP6MPgHWcKMzfYroM86A7cxtreK+WXp1nB2mvksP2HiFQB Md77Dc2sSLIk36Peto6npVTnl9Yf4Qk0LPnxdXLMPgKY+4pgZ5frcvW01Bdl1d/F4XSl xdZ8ne/4eh1+8Qy7/MF0YYmuSBHxQUQqbL34QGWkwH/6bjqo5IE259p8nXexMA5BrGZG 5Bkk2bHSg57PRkKnfFpQCiAiY62jZVqDgbkXEc0OB0YNDCDi4gx9OegprMpEoUGN8bK/ HW9Q== 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=KP210xakE0fnC7vIvk0imgJs+fS9ADi790NzA19qrHY=; b=sZT51jCDQXbu+TPioGOfMEgJrajog3U6tLlhTDLvm87wWxHjNmDMWhGa53gxBBuwLD EJJMidbVou0AC5dn//72XSxAU1c4hsO3emDWYFJBONj5xBenNLNKSi3Nk8iDvpZQeHUh yMnfLyg7jHXIOjruzmx5B23aZFlHyG/IUlYpc7mNqvQ3t0dhApxVrgJN679/CrvN5wWL 33TNh6TXgs8MatNZbC9HqmD1M7UkAfaRWjNmp7lQ1DzAtjexzadS9QleT9WlOwBy4rCf X6QdBP6YMMtVhb7b9E6bpXd7/YNzGW2HofT6/TacV1tRNmTSROeH+n2YMayWtiQOmJ6I QvBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ufbu1A2G; 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 cp8-20020a056a00348800b0052e51263b98si13589738pfb.249.2022.08.23.04.29.38; Tue, 23 Aug 2022 04:29:49 -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=ufbu1A2G; 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 S1355657AbiHWKgv (ORCPT + 99 others); Tue, 23 Aug 2022 06:36:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354636AbiHWKVw (ORCPT ); Tue, 23 Aug 2022 06:21:52 -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 879B9B0; Tue, 23 Aug 2022 02:03:15 -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 0786CCE1B40; Tue, 23 Aug 2022 09:03:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FB12C433C1; Tue, 23 Aug 2022 09:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245392; bh=Y4E9AUuRmEGnt4oseXYaISQM3DxMntE5xEb8spHMl7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ufbu1A2G5jpkuHygqny/EfYd/JRG2ejxDLTgdjJzKlQc88tBrbRkr6dFDAw0g2VOB bAfNc6iyVZNlwPM2atMSSi/opZeo9ykHCJxJ9bTGSRMOL9ZaZ+b1v9ayk0pZ+3A/6P V18dFI7Z6v8qA3h64ThLMFz69tjjzomKqlSRgmhA= 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 4.19 064/287] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Tue, 23 Aug 2022 10:23:53 +0200 Message-Id: <20220823080102.394630573@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 b255590aef36..b2bd7ee46c45 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -189,8 +189,12 @@ static void of_get_regulation_constraints(struct device_node *np, } 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