From patchwork Wed Jun 12 13:17:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mishin X-Patchwork-Id: 13694973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 736AFC27C53 for ; Wed, 12 Jun 2024 13:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=sHLWV/zF6E7dCy7EgzBUyyoPsCq43FjnuXPUVgA9yfY=; b=0zAocr59XmX8srjJtftBmshHbY 8XiXqbfMGtRuUV2aTKOu2cO3Eayi4fuwSEP2NsVv9MTScydaPgyYwuKlXiEIoVLzyfgEeVYm5RW48 B4jbspZJ5RYGS90QjH62RxrZzvk9WrIYmw5bnK/WDSg1ls8yJa3jhA8eQZWjN6+1RUowJG28Bw0sv zlDamOhC+erwPxoaO4ZbX4moEOUYu/tXZ19AyNYsijihCNY2FiONyxeEGv4SiH0EOfJFl7NbqVE+Y sz8f7PfrnABGc5CpdzNjyI7CvC1pyMzg0cDduNxu+S/Mu/MYLqvA2S5RM16M0uwtc6gIT5DQ39KZW er/FkJtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHNto-0000000CiFv-0mzU; Wed, 12 Jun 2024 13:20:24 +0000 Received: from mx1.t-argos.ru ([109.73.34.58]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHNtk-0000000Ci7O-1yrS for linux-arm-kernel@lists.infradead.org; Wed, 12 Jun 2024 13:20:22 +0000 Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id D11DE100002; Wed, 12 Jun 2024 16:19:18 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1718198358; bh=sHLWV/zF6E7dCy7EgzBUyyoPsCq43FjnuXPUVgA9yfY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=c2txolqsqoc2RJ1zZ1hGiqbBqVvmuQl2GRECTtj8+ESOY8GGm0VdUBLRsJ1c0/rQD WxF1vcolTZgpFd/0XbIb6pmCDy+ihHLY8z4gHilSTmmOa8AnGPqiHwdNBVE1q9kU+v iVEtxQ+cxQ7YN2mEsfR9kVJDUkckb9cZB/C8DNCNOrYaMvzwtwa6IWbwTvNaUtdBxq Zdax1O9KNL8T8McFPCd5+/Xks9fO2t8rHYjqMAnAy/e1t8YcugNqU6IRsXzFdn5bTQ lS6YysTZjXSsegwpLNwoyN9TprdsV0lR5Ps1uS8OlqdrSW1edJCyDrN3JpAmla44yV 2kg/hV8VT7g+Q== Received: from mx1.t-argos.ru.ru (ta-mail-02.ta.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Wed, 12 Jun 2024 16:17:51 +0300 (MSK) Received: from localhost.localdomain (172.17.215.5) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 12 Jun 2024 16:17:31 +0300 From: Aleksandr Mishin To: Peng Fan CC: Aleksandr Mishin , Bjorn Andersson , Mathieu Poirier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , , , , , , Subject: [PATCH] remoteproc: imx_rproc: Fix refcount mistake in imx_rproc_addr_init Date: Wed, 12 Jun 2024 16:17:14 +0300 Message-ID: <20240612131714.12907-1-amishin@t-argos.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Originating-IP: [172.17.215.5] X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 185880 [Jun 12 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 20 0.3.20 743589a8af6ec90b529f2124c2bbfc3ce1d2f20f, {Tracking_from_domain_doesnt_match_to}, t-argos.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;mx1.t-argos.ru.ru:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/06/12 12:51:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/06/12 04:43:00 #25560246 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_062020_860315_B73A0818 X-CRM114-Status: GOOD ( 12.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In imx_rproc_addr_init() strcmp() is performed over the node after the of_node_put() is performed over it. Fix this error by moving of_node_put() calls. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 5e4c1243071d ("remoteproc: imx_rproc: support remote cores booted before Linux Kernel") Cc: stable@vger.kernel.org Signed-off-by: Aleksandr Mishin --- drivers/remoteproc/imx_rproc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 39eacd90af14..144c8e9a642e 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -734,25 +734,29 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, continue; } err = of_address_to_resource(node, 0, &res); - of_node_put(node); if (err) { dev_err(dev, "unable to resolve memory region\n"); + of_node_put(node); return err; } - if (b >= IMX_RPROC_MEM_MAX) + if (b >= IMX_RPROC_MEM_MAX) { + of_node_put(node); break; + } /* Not use resource version, because we might share region */ priv->mem[b].cpu_addr = devm_ioremap_wc(&pdev->dev, res.start, resource_size(&res)); if (!priv->mem[b].cpu_addr) { dev_err(dev, "failed to remap %pr\n", &res); + of_node_put(node); return -ENOMEM; } priv->mem[b].sys_addr = res.start; priv->mem[b].size = resource_size(&res); if (!strcmp(node->name, "rsc-table")) priv->rsc_table = priv->mem[b].cpu_addr; + of_node_put(node); b++; }