Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3408580rwa; Tue, 23 Aug 2022 04:24:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RB3Fb8iDPsKB9HlafOhC+6OM354WAHJ7K8E8d4RF1bWSwJaKamiGUWti+hS/qd8JGU6/2 X-Received: by 2002:a63:f446:0:b0:42a:a729:18f0 with SMTP id p6-20020a63f446000000b0042aa72918f0mr8168626pgk.589.1661253865723; Tue, 23 Aug 2022 04:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253865; cv=none; d=google.com; s=arc-20160816; b=gW8gBa+GAy/ZlIKn3psohZEUD7PYXj+xmef86DTcwKVUy36dHYRCDH4uqWeE+XoGk0 nk6dplW8drQ7rfZ4vLLkQoONaV/hRg3UxuvB57dhnS52QGrjU5dCgAebJsXEPkr6DLPy IBJFreVheHcEOmxVSviTtxP8D4aT/ok/vvm400eiXGT0cGv7vZDM1j9ku9sBHUwqj3cY dhb+oSzWTeHUqLhKZxhkTsqDp4jeLGbKvwPocfpikpLMNoXI7D2OJkEzI4RlX438j6ku 4SneTrx8lHMnpdb53bXaSvSRjGXIvMu1p2SLCmwsjiH5ztaL5aVPZuFhLNxVn60Lqyeo WnNw== 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=IkbwsVfm7cg7/ayRds/aNaumNOCUzwfiHB/JLicVtWQ=; b=nwDhMVUcMVIli7Agw4+P0HeHdrKncRLJHLDDumwOnQVQm8WtD9W8Wk+rQ42td4YBns AYpuJzeY+mrNpTrX6urq0YwhhTtHhLZk9H4ys7Ampn0W22kqk03gGmWUsiSrr/fbRekf RcG2wFU36znfEnwtALyHGDoluEyyWZJjDHeNcGfCjtPwgqgRTOFmAknfZoGIvY+lgyRC cwyZ7roMO97+8SrtPcCN6skRe3CR4L14yXOaxHIUhQz7s0coVcKDktk+OFKRtkfgrc5F Ak0Al8LLZoUlqrJSA9dIkeX+0K1hm4VDfV8uk+UOLgD+6LjmYBHCTlx2Au72k1GRVIWX aDCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j7bZ8yo5; 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 u12-20020a056a00158c00b0053711e43bdcsi581996pfk.151.2022.08.23.04.24.14; Tue, 23 Aug 2022 04:24:25 -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=j7bZ8yo5; 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 S1354040AbiHWKTu (ORCPT + 99 others); Tue, 23 Aug 2022 06:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352720AbiHWKIf (ORCPT ); Tue, 23 Aug 2022 06:08:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1BD26E2CF; Tue, 23 Aug 2022 01:54:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7B4EFB81C48; Tue, 23 Aug 2022 08:38:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6E4BC43145; Tue, 23 Aug 2022 08:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243927; bh=drOoGIBMOeRwHmzS4ziAXbQ0TDul30Lkh7ed/X2k6Ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7bZ8yo5AO+fJB5yHu/wJE2aT4po1Z+cTg7SjkgnT9U0Wzjk1uYtpptlFPeys6Sz7 LIoTKlMqx8Y0cF0MxvRFk/kfy6z/uS0XodTU+lvX/g11oXTi+jswm4mz+clsagAezp Sc/7k6aaetVm2TXfXOvQrd9xoI88vemY9G8KQZw0= 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.14 057/229] regulator: of: Fix refcount leak bug in of_get_regulation_constraints() Date: Tue, 23 Aug 2022 10:23:38 +0200 Message-Id: <20220823080055.767674846@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 a3bf7c993723..f82b522bffa7 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -158,8 +158,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