Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2815636rwb; Mon, 15 Aug 2022 11:55:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4nPDEFT/t+ZhVn0neAkrbwdiTFqgJDl2i3arEjZ7J4t05q4Xoe5mMNUujSIwwSCs3z9f+y X-Received: by 2002:a05:6402:358a:b0:43d:aa71:3033 with SMTP id y10-20020a056402358a00b0043daa713033mr15681041edc.248.1660589733780; Mon, 15 Aug 2022 11:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589733; cv=none; d=google.com; s=arc-20160816; b=YTkZ2pyhsFg4/TTAnysb32oteGgeQa8KuhAjJrltDQuytEEd/h7O18apQtaC1zeR/U cPHcEoucHijS9BNPKSI2z4hXI+NBrfmXyusnyMEFazkWGR/vNRXG2tBUcLIL/LjhP0TO XsYyLZA1y8ufLK+g2DGIubAKVbEvJKaqXUpZg5sW1ov0OYy34vrBmxhgcBXhdpRAB4gT +aSAoS87qlXHS4dMgp8cNEuwfUXpbRaqUipOd8+OLC7XX4cp8v1Xn6d6T3xqni+8eg2+ 6XiG7up5z6ENpPh8/+kqLcwE4zGbRg9lmbrt9ys7k5ucamBtDgAprcQ+G8n7Nhku4ZPO uJGg== 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=SYxlevNBSBXpYWBqiYwlaFekIsL1XPemLMUvkmXtpkXn4D41+xRvCkDJx6X7D+SkhE 9e9/R1UH2jgHnxeKh26IrgCsBwugePWFb7lNbZEehFIgrb3uW64WWm6bxOrtGjM7ui+R gz9D07w04DSLshp/XzwAbkZyvfb0C+xwlT6TyYPiKSzAQP7I0jAEH8uUYAXdF6Kg9Hlh TLBouNx/yLK5LOwIze8uwtwW6yjw8uy9X6HP3xjk6Dhp+WAgtcf9RTBs6mk5SieRDPQZ 64eQ8WKhRI717b+kNmcGxaGMola8MQhJ5443Ad7wg7EfZvQB+Yc7vVJ/5xvH2RIziwUB QYcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="oX8Pr4p/"; 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 x44-20020a50baaf000000b00440a49861dcsi7771787ede.412.2022.08.15.11.55.04; Mon, 15 Aug 2022 11:55:33 -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="oX8Pr4p/"; 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 S243002AbiHOSnK (ORCPT + 99 others); Mon, 15 Aug 2022 14:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243161AbiHOSks (ORCPT ); Mon, 15 Aug 2022 14:40:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 072493E744; Mon, 15 Aug 2022 11:24:26 -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 EF82060FB9; Mon, 15 Aug 2022 18:24:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05C16C433C1; Mon, 15 Aug 2022 18:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587865; bh=rO6j8LMjktGpC8KRSmNNYA45x/kxmmEIE5Y/UjH+cug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oX8Pr4p/R1yipBvu2Nx/SB60huTemDmwoFr3FYw/hAMc8chTGG/UqymWvnnH3Z2Cu 4i7SlUw0i78B3MB5QtxlwHy0ZOXLU4eDotuquBEaf0P6J7OvUoB6SV2/sntobP/nbc fdjGd/Ol+xFjSLY/a0cOxw0WahA3BQ5hnrzIkcw0= 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.15 218/779] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Mon, 15 Aug 2022 19:57:42 +0200 Message-Id: <20220815180346.599459531@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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