Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp960363pxb; Wed, 6 Apr 2022 05:22:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsJFFH28XgPWE7jZeuyDXMhEdN/i1MReCM6bxm5/hJ55VUNd9wIcPnh7tt7roXF7BXOdQ6 X-Received: by 2002:a17:902:d48c:b0:156:956e:4588 with SMTP id c12-20020a170902d48c00b00156956e4588mr8094163plg.105.1649247753035; Wed, 06 Apr 2022 05:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247753; cv=none; d=google.com; s=arc-20160816; b=tRVtcwCcZptYvHbmGJdJqJSR0/g5+QxHqIZ1yP02Geg1c/2ufnJSVtuI8KlWO20hDM gLAU34MAlcwqLxapTmJF0wGe/2IsHzZy3Y9Eq9nL7NEyXXn/Dg1fKj4H0BSIFpIs90mY /cOhE7eX+/3tk4ZXGUnG/MTKbG8eqdC9Knp/w8MfNVlMMqlNlWoz3EtcDex94Y+c3t1o KWhCqzzAFuS4GDcjBfN+3Q8Q3qzbtMc0BLobrJ+Lp/7OCHPQAWgW6PM14mW0lLmxW3sn b6oLfSbySuxKubO7MI+xr1RHzIy6zZYLq9KxFQ+voeLRsas8Vpi9gbYu1ZdtSUBKONAH 7V3A== 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=AiYoNRtYRBannQCNa60VFUSPQj9HGbdTNrETTBBCkyk=; b=TN98CifPsjPEhRhYuxbWrCnEZM2Q7diady6HzlZdrQhBewvflIlZBGskft6G0w1Nv3 yHk3GN7IJ/H8wXheg1E7I9QGOm8N6QbAHNbnEelgnj20T0Bg1QFx16jphdygZnLB6XEO 3RcUOn7AYS3qZSrrxHoMmrTqhyZidVVYM3HEa2J3TFoCHoPRouI2BHRe2jtVol1dgvb2 hs3efLt3NOZymH/R6aJW59ve2fev9BX8sttO9NuohzO+iWXToAPEURYuqSI8nWAxSOmV 9J/vyl6RIyrPqmtXU0hdYClT4t82lj7Wz1VBrlJTAbDrQWS9+q1/gYOIZI7MMfn2DDzF krWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ji9w8NH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t1-20020a17090a2f8100b001ca8987c767si4391273pjd.144.2022.04.06.05.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:22:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ji9w8NH8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99F146D994A; Wed, 6 Apr 2022 04:20:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355294AbiDEVZD (ORCPT + 99 others); Tue, 5 Apr 2022 17:25:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349474AbiDEJtz (ORCPT ); Tue, 5 Apr 2022 05:49:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE3A27CEF; Tue, 5 Apr 2022 02:46:58 -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 9A195B818F3; Tue, 5 Apr 2022 09:46:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04B70C385A1; Tue, 5 Apr 2022 09:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152016; bh=gNHrehMZgZje2ewnnw7KjUsMgqBeRD6jduXfTGBTdkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ji9w8NH86koKxRRmKPJLir9PAhyqJByrPAL9HomQ2X8BNlBuOnufxG6iiiiBsakcQ D33zHaZkgH0ZRWMCyjGskIfHfR2aZOxRsEQqlm7M5//Vq7EJ+S3go4Gp4d+vB9Abjt 5+DyrPn6fDhepkuSCv5Q1nFzWkFlLBQO/2YFq/D0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 617/913] remoteproc: qcom_q6v5_mss: Fix some leaks in q6v5_alloc_memory_region Date: Tue, 5 Apr 2022 09:27:59 +0200 Message-Id: <20220405070358.335445001@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 07a5dcc4bed9d7cae54adf5aa10ff9f037a3204b ] The device_node pointer is returned by of_parse_phandle() or of_get_child_by_name() with refcount incremented. We should use of_node_put() on it when done. This function only call of_node_put(node) when of_address_to_resource succeeds, missing error cases. Fixes: 278d744c46fd ("remoteproc: qcom: Fix potential device node leaks") Fixes: 051fb70fd4ea ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5") Signed-off-by: Miaoqian Lin Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220308064522.13804-1-linmq006@gmail.com Signed-off-by: Sasha Levin --- drivers/remoteproc/qcom_q6v5_mss.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 423b31dfa574..ca1c7387776b 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1624,18 +1624,20 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) * reserved memory regions from device's memory-region property. */ child = of_get_child_by_name(qproc->dev->of_node, "mba"); - if (!child) + if (!child) { node = of_parse_phandle(qproc->dev->of_node, "memory-region", 0); - else + } else { node = of_parse_phandle(child, "memory-region", 0); + of_node_put(child); + } ret = of_address_to_resource(node, 0, &r); + of_node_put(node); if (ret) { dev_err(qproc->dev, "unable to resolve mba region\n"); return ret; } - of_node_put(node); qproc->mba_phys = r.start; qproc->mba_size = resource_size(&r); @@ -1646,14 +1648,15 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) } else { child = of_get_child_by_name(qproc->dev->of_node, "mpss"); node = of_parse_phandle(child, "memory-region", 0); + of_node_put(child); } ret = of_address_to_resource(node, 0, &r); + of_node_put(node); if (ret) { dev_err(qproc->dev, "unable to resolve mpss region\n"); return ret; } - of_node_put(node); qproc->mpss_phys = qproc->mpss_reloc = r.start; qproc->mpss_size = resource_size(&r); -- 2.34.1