Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1865342rwb; Fri, 19 Aug 2022 10:40:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NOF/YwsIvxjsEq6AuSOGIIjddMuGZ4BKz/vnRMc2N8gWMt5bJb24ZPMCfXcVAo9tewEUe X-Received: by 2002:a17:903:1209:b0:16c:ece7:f68b with SMTP id l9-20020a170903120900b0016cece7f68bmr8439946plh.112.1660930825201; Fri, 19 Aug 2022 10:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930825; cv=none; d=google.com; s=arc-20160816; b=g4xKnzfFBNM+k2nsorfx0GKn4+KOafu5lLu7nETN27VtsCIF0Ip3pI5UPihAZR8/4X UDxJEjyp1kPyHZmDbXIjgGnV/i8FRtJWC8wFQZ/kUt73AfcS3mw3qZswxxsovV7y4n14 PADa1YVe+B1JgaC9eriro5LTa4EMCIYeYWq1BHVjlYx4HJF0BW+lGqgDkYCgOqO19QIC P6MVBe5fjxT22q9Sw51dCz28Rax8jgRX7jsG8vwSQFLu6Gs35fnRWZOyrtbXQlE6KufM fnin50NZzBV8FaHkCKIRLJs5iTh9P6R+pV8McPvEbkT4RO66rZ+krTOJw339bPDlRMK7 /LuA== 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=daoYtfeY/scZv6ok/mbT1oJioKm/ZgnRtl3Z4uxUGOY=; b=RWaYxXNtrfWrnOQlWVOrKCVICFqx4g4KboR8T9EqKuP+340LcQHzB5cZW09sPCgmdr bmjNYK5GF2zs9vc5f0T+r0jzEBoFQ8HQt87ywFglRyqXchPThvaoCvPN9/I22aW50a8H gRVvritBQqfUfrYx2G63I6YbGi038/Ii1TYeAxriHvfKWOUnUmpV5uqFUiNloDcm+Xup jpPWJzYQSeGfx2VdIfYc0hRPtWYGEc6pBcl5tc7nfxHxEyMOO2c2656gMCQH3O5dDXAR BXfDCSmjFYNNdl4bFZHC7F3ASM89apNqZp5haZN9p9dfm0l2u6EKOvxcw0EOVLC6ilLV 1xpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vo8WdwDu; 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 j1-20020a17090a7e8100b001f2df5559dasi4337611pjl.115.2022.08.19.10.40.14; Fri, 19 Aug 2022 10:40: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=vo8WdwDu; 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 S1351047AbiHSQAZ (ORCPT + 99 others); Fri, 19 Aug 2022 12:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350960AbiHSP71 (ORCPT ); Fri, 19 Aug 2022 11:59:27 -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 F4201108FBB; Fri, 19 Aug 2022 08:52:07 -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 0D922B82812; Fri, 19 Aug 2022 15:52:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 415A3C433D7; Fri, 19 Aug 2022 15:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924321; bh=qFtJTFkGXlUimLZQdQpb9oM5fPuVizHi3ChcOSFqcV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vo8WdwDufZTnndvifm71IZTHUylGGybiLfNLbLSiXDpYk2AHyiZIih2GUw45okp/i ImlHbdZNAPUFT+OeqkcJGJX+/6ZTiuqSAtheiZY96G0sNVVmiOAoHKNoijxnKx8rtD tFXwQkBFg9MQ4YtGc45wXj+MFscsLPlHYxY8mu3E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Brian Masney , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.10 132/545] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Date: Fri, 19 Aug 2022 17:38:22 +0200 Message-Id: <20220819153835.238280205@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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: Miaoqian Lin [ Upstream commit 92a563fcf14b3093226fb36f12e9b5cf630c5a5d ] of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. of_node_put() will check NULL pointer. Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver") Signed-off-by: Miaoqian Lin Reviewed-by: Brian Masney Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220602042430.1114-1-linmq006@gmail.com Signed-off-by: Sasha Levin --- drivers/soc/qcom/ocmem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c index 85f82e195ef8..1dfdd0b9ba24 100644 --- a/drivers/soc/qcom/ocmem.c +++ b/drivers/soc/qcom/ocmem.c @@ -194,14 +194,17 @@ struct ocmem *of_get_ocmem(struct device *dev) devnode = of_parse_phandle(dev->of_node, "sram", 0); if (!devnode || !devnode->parent) { dev_err(dev, "Cannot look up sram phandle\n"); + of_node_put(devnode); return ERR_PTR(-ENODEV); } pdev = of_find_device_by_node(devnode->parent); if (!pdev) { dev_err(dev, "Cannot find device node %s\n", devnode->name); + of_node_put(devnode); return ERR_PTR(-EPROBE_DEFER); } + of_node_put(devnode); ocmem = platform_get_drvdata(pdev); if (!ocmem) { -- 2.35.1