Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3027759rwb; Mon, 15 Aug 2022 16:26:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6WXsANoWOjNARXboTZfi1MuN5k6qDK7Ie2FeMuWinl3pHB9ILjiP1CiOe13YLCcd/L+Pi7 X-Received: by 2002:a17:907:a427:b0:732:ea25:2d38 with SMTP id sg39-20020a170907a42700b00732ea252d38mr11575670ejc.87.1660605968207; Mon, 15 Aug 2022 16:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605968; cv=none; d=google.com; s=arc-20160816; b=Y0IdBdKzMP4PYOdm+/+9h9pcdifJti66lw710grP5q0T9Mjqknn1Ywj/K2ed50ZSZb ad30IwxmJWUlCiaWbG6uxGcGb+PMFfXxwEPFXkg52bAPwSmMKGEzSAuhvdJZUWlCMBjC tVE87CKlqNcz8VLr8MKbbB+Q6WC81Rb7B6GxmDqQ/LlIAZdg4NvzUP1sVy6EiuK6vrzm Tzqhj/Cpj4iGBXEJG3egOsodUhxg1Vvy67zB6fVg1ec4iJZDgMM6WJ2C3boQuOsskABz 2PVcgPGYkkUUzXz3qXbggNzsgI2YJlk/ypyvcJFscMuQ9LUAsBre6XLHdg/GYUm+KtJn BvYA== 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=Z8/n6h485HskHOA5ZvCpD9dFIbEUBLc9SJBwNy15zeA=; b=TE/W+N+G1D9qnl78vJ7OnjXpb2M2VYNv1mwKDrOTzOBe2Qv9FFUl6QOd38vvAjEnQo wWqZtw5dJzxI1GTROwx/T4xeCq14N1nb4JhvYlZZYPP3raJO8YbZe3pyXYxYr2xAA7Zy jMntnSJWNCAIJqpd0oXHrlgxElmgFrOYsLE/Gg8/h6H8kOG7/RqFyxxcdSNx+sRHH3tW selUK/0pn75pm9pvSz3zvz0xLKAnSnFzO4+9iqGdu4/8rWEJ36tT/13RcD6JC88ck8cW yUIPZAu43uC6wLfYR7nvlvAb5pDoPPSsOEs9OP7wKaSyECHnSz7nmf4sIGr9lWrR1rDu lhFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CvUQPq23; 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 dm5-20020a170907948500b00738553043e5si3562385ejc.573.2022.08.15.16.25.43; Mon, 15 Aug 2022 16:26:08 -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=CvUQPq23; 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 S233551AbiHOXHx (ORCPT + 99 others); Mon, 15 Aug 2022 19:07:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241419AbiHOXD4 (ORCPT ); Mon, 15 Aug 2022 19:03:56 -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 6B28C86065; Mon, 15 Aug 2022 12:58:29 -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 0828B612AC; Mon, 15 Aug 2022 19:58:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB0FEC433D6; Mon, 15 Aug 2022 19:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593508; bh=rO6j8LMjktGpC8KRSmNNYA45x/kxmmEIE5Y/UjH+cug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CvUQPq233F+z6aGmtcp4PapZngqQdikSOvAgkAtKvPyoIcIgWIyJRbvXHPX9iP8sK awzOkQVG9L7iwx7Ha+oMGi+7Hsjmp1augc40jMxOxKQ/JN/8f/ycGvwYJ6cdw41gHi Uvb3a8u8G5am0yTTeqY+0crgXPgDAvP584JXwoSw= 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.19 0280/1157] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Mon, 15 Aug 2022 19:53:56 +0200 Message-Id: <20220815180450.809683939@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 f54d4f176882..e12b681c72e5 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -264,8 +264,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