Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2814086rwb; Mon, 15 Aug 2022 11:53:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5C1g4HLfTYyLvahPnRkBUfW4YAS44ya5k7re15+awC+GS4z7JM5rVYWk2hg9zZ/ns95Y92 X-Received: by 2002:a17:906:98d5:b0:738:3402:197 with SMTP id zd21-20020a17090698d500b0073834020197mr6534942ejb.581.1660589600096; Mon, 15 Aug 2022 11:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589600; cv=none; d=google.com; s=arc-20160816; b=Bu0/zUHSbU0xZATSAdnI45344Ac2u0OcaTLsK6lSTS4LNoqDcoKvcuG2Fy14UuH6Ia CpviZL3M4agOKgNyyge8J6CmYnwXJdG2s4N4s+6MJCysbLf3HNWev8B2HRkHZQoOqhGR weSDNm6wFRkSkG/qX5WeNbjkhWyZQGjWmvABKzBCxeWsjFJxqLmjs1axpUdKA9kGTZxB SA33B8HEJIL+KyPMmbiI9yW+Ry6dZG5/iw5d4nrCux6tmo/JTt90CDCS24G3TAyBvjGp 1uT7H/v95iuE5IR9fQZk68nPlcqpozZxD8JDaXyqdSo9ABYfqbTOWppDFaTXMh7i8Pba vMvg== 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=Ei915/SERNzJDZUeONRowMaa9CaXupbKp5PqsSILiDkZ0eZzaNC3fBhvb3KsatCnGS 1nF4rn9ZaNYXhjhBqmzouq2X8Lairueio69UM9dUNa2C9g+YdEU2clMmxeJhhqZpITif mOa6DQzBLzRqtHSLN56S0JRv2hCk+g2dExTcUFPvJADzbABGXgz+mhOfML1SkBbUDFyG 9UT6YrCJVc4NIndcMZLdhg/3nmoiFA4GTs0pMLRUHGbNeTpc1J2PFuNj/ne2G3xgF6zQ H9+go+y0Xvv5h+woPJk6ztwc3gTfOudhIrvrXloDuGEu9yMWDVY9l1wxOy9yxXPAX4r0 eV2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tcqHxI6Z; 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 d18-20020aa7d692000000b0043e0ae90679si7951284edr.610.2022.08.15.11.52.53; Mon, 15 Aug 2022 11:53:20 -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=tcqHxI6Z; 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 S242794AbiHOSnC (ORCPT + 99 others); Mon, 15 Aug 2022 14:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242672AbiHOSkl (ORCPT ); Mon, 15 Aug 2022 14:40:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCFB53DF37; Mon, 15 Aug 2022 11:24:22 -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 C1438B81081; Mon, 15 Aug 2022 18:24:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1DC8C433C1; Mon, 15 Aug 2022 18:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660587859; bh=qFtJTFkGXlUimLZQdQpb9oM5fPuVizHi3ChcOSFqcV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcqHxI6ZThfVvjmcfOOBgJYNsmt37p/Ep1eGvGhBHX8+uXQEQQlU2unToLDvFuATm X699PT2PfzfJh7dRXBWkNTq76NQ53ghJxG6BKrTJOuZ9B2NscMe61B6+0v0+gaVorv /sP0hTzveRwVvxwQr8BR0h84Dp8cRX+Gll9fUXGM= 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.15 190/779] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Date: Mon, 15 Aug 2022 19:57:14 +0200 Message-Id: <20220815180345.372294228@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: 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