From nobody Fri Sep 5 20:17:16 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 F3526C49EC2 for ; Tue, 23 Aug 2022 11:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357465AbiHWLTU (ORCPT ); Tue, 23 Aug 2022 07:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357681AbiHWLQ1 (ORCPT ); Tue, 23 Aug 2022 07:16:27 -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 3FF40BD135; Tue, 23 Aug 2022 02:19:55 -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 CDC0860F91; Tue, 23 Aug 2022 09:19:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5E46C433C1; Tue, 23 Aug 2022 09:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246385; bh=LxlD/8ujn5yKi+sB+4/WqDi1V5LJncly6CvjUyKfZeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=csYyc5B4cx8IIhbFP0yKeAQ2DoyTDQ4b70NIHnv2SHTP8jWSQC1phFaFxAG4vygef Wrq3NOc255/rmVbshjgAR78VcXxRxT+SO4iJ0LRjq2SPaV3Pq1F/gRk6Optct+qiIi bxqbDSoKiH8PnmmOPIOlLZGwcYEgys09jf1n9zl0= 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.4 091/389] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Tue, 23 Aug 2022 10:22:49 +0200 Message-Id: <20220823080119.416017114@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@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: 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_stat= e 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_regula= tor.c index 87637eb6bcbc..7a0a235e4465 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, } =20 suspend_np =3D 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; + } =20 if (!of_property_read_u32(suspend_np, "regulator-mode", &pval)) { --=20 2.35.1