Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929041rwb; Mon, 15 Aug 2022 14:14:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xNrKbhjUj+6EUPKT0glh/ATPlI6D2RwUhPIJrVarfGdObyRDg3UjDLyufCQa1mB9++Wju X-Received: by 2002:a17:906:7952:b0:732:f993:75bf with SMTP id l18-20020a170906795200b00732f99375bfmr11760973ejo.165.1660598083575; Mon, 15 Aug 2022 14:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598083; cv=none; d=google.com; s=arc-20160816; b=oJDXrkjkLzZpWWbKoGxOhsNbF2UAESO+tDPUmxU0IzDcDG4VQtjgq30axwwCpClblO haAqD24yyRoB9a7VaXU60P/t6CosfQ5/mqMw94i6C9DWU5Ofos2kgrFJu03waRCr1uY+ SZEkOM1kqROMRpSg/ynTVJRVDB+EEbYj2eFGPTWVOiMdAgmlYAwQbRQLav/SOtwJtQAh KIHnvTw0Qe7t3DYTfBpR53FLtnAot75Z35w9Tzaxa/6NyhdqC4OI2n/ua6Q5uiBwgrBo +vDSZzwYKsWaI+0luG3FAz8Zq9It6NG+kV8GqYzQct2SerD2N4QJqMLmc6CTXE9nPsWH FXgg== 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=FwR1Ra3kB7rOHQASUDRtrmg9iOdY3qxcJHPuSBpgzfPmqzXVjFOKDrpBd9e9DStBR2 ph0UwoOtK/Ypa/j/FHmyZTw6812zctlFDPST2VJMo2836FYgt2Y2C0TxusuPk6Ecq6qj Fp35TrYCjoQ0frfwSaNXe/1HGjLXKyeul5bogo2IRu7cviwMZzUnYgSWggQ1pYzkpRi2 abcw8VZixhD6uEnpczLW5t6Zk5y0xefFYVFK3++JHXrBUqFn1VvqWzCRQRaw6Ip3/otk +E39ETkeUazFkZke7m2LMXqUKq1W+NwJZQzADyTps6BhxGM6YRozuyhSTsZ6G8mxKZcC Oqog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SlBUa6fT; 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 js17-20020a17090797d100b00732fd99cdb5si8386009ejc.854.2022.08.15.14.14.18; Mon, 15 Aug 2022 14:14:43 -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=SlBUa6fT; 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 S1345501AbiHOUrB (ORCPT + 99 others); Mon, 15 Aug 2022 16:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345694AbiHOUo3 (ORCPT ); Mon, 15 Aug 2022 16:44:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D800EB6016; Mon, 15 Aug 2022 12:08:19 -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 B52386069F; Mon, 15 Aug 2022 19:08:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA92C4314C; Mon, 15 Aug 2022 19:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590498; bh=rO6j8LMjktGpC8KRSmNNYA45x/kxmmEIE5Y/UjH+cug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SlBUa6fT6v2913QBWofRH8bPIwWHT8a5uQjz8bTu4FGrlSZahFinn48wu00pkJ0bb yL0UBOMyYdGb7m4qcmfr2ZeaQGerm4KooK81McJWy8eDmU64EBZHKWhAyyXggakp/i KOUFLxKuBGUbaOKpJhit3iE9VTN4v0fby4Sx2ILM= 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.18 0279/1095] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Mon, 15 Aug 2022 19:54:38 +0200 Message-Id: <20220815180441.317863224@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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