Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026659rwb; Mon, 15 Aug 2022 16:24:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wgmXbUpYXuAZzQ7+g4mtPfAi52LH/GVrWTjiiA4Nc1sunJv3hguJwAS7Plmsm1tDE7SvD X-Received: by 2002:a17:902:d584:b0:170:8ebf:2048 with SMTP id k4-20020a170902d58400b001708ebf2048mr20053583plh.113.1660605888438; Mon, 15 Aug 2022 16:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605888; cv=none; d=google.com; s=arc-20160816; b=i3G2cn0dq0hk/pXXWDxVQqmTplbr8MbRCA4rBktHyDRN34JqojtXc+TK3JsHZK5tSN Hp0/eqfXEYZZ9Yj/b0CSrKZFxkOur0L2rQMys/p1gTVXLmZoW/mIWR3kn5rcQaLUgSjH OONIn/UiGUOuFY0zJgQwzThuf7ouDr0nzCY/NujmC2HOS7G/IuIR8+pqYMQ52seiOhxY mI1EEpZ3G5QyXyqO9nkELj1X+iGAuuvKPa+8RSE4kAqCUdBawHqvpab/2MxbET3c+w3t MKzQBn0ZMITOX0vC3PpIkk05SuKJstoeg6F9d5hbJ/0axhJYpk55zyQXh0aptM5jWwUv 1fcg== 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=QUDBtbEIXfD7ei0FdipOV9sXHTsdyMY1sIjQMQUFM0M=; b=X0sk86G0t/5yMPRAymDtmfALhGgao65I/lHSTOQFXOMQ3aNOkx+AHx+/MbxzoVwx5D skxUwYE9Wod/up9aH1Soi374yh+ce5qAILWoCDirJ/4lfunzB70IiOD70qd333Sk6oYN T5AAds415ELBtcJo11W5Ni62Xe4aQcmY6++u9gCK6onrKT3R5xKDOyvO1sowlTXTjsYq ks3dRLW/rWm4T1+J+8RNx5+JLVVFYq0PxWblM/myqUfW6e6VQ4Ge5bj57KyhNF8k+IS3 EM0FQX2Tm/L+Mssjs80VaF+j34YY/BtONVr0pJ2ioRbaEBJPyD9M5BiN69pXyOZOrc/p hPSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uSkipxBj; 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 190-20020a6301c7000000b004224a9f5db0si10323270pgb.49.2022.08.15.16.24.37; Mon, 15 Aug 2022 16:24:48 -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=uSkipxBj; 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 S1348050AbiHOWzT (ORCPT + 99 others); Mon, 15 Aug 2022 18:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352242AbiHOWxe (ORCPT ); Mon, 15 Aug 2022 18:53:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D66DD45076; Mon, 15 Aug 2022 12:54:46 -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 AC25A6125B; Mon, 15 Aug 2022 19:54:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB419C433D6; Mon, 15 Aug 2022 19:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593285; bh=j55TNd95ho6ZbsHNHDPW0cph+TjLYNpouX6nY95nTmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uSkipxBjJx9dfeW52fXuy7MlMnNhwbWDgj4IqXf3RfVhXouPmBYu663JQejwJat5y BFkPZwCYSC6Uu/L2bUie6ajoCpKCxgCbD4CRson/Z43FJ/Vnqvqod7BrftUG2D/iJo V4MN1DRuFGM7NUwUrq/r8YMeecjQ05kEuAzKkEpE= 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.19 0241/1157] soc: qcom: ocmem: Fix refcount leak in of_get_ocmem Date: Mon, 15 Aug 2022 19:53:17 +0200 Message-Id: <20220815180449.198484131@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 97fd24c178f8..c92d26b73e6f 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