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: 13694974 Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96FCD16EC12; Wed, 12 Jun 2024 13:19:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718198388; cv=none; b=ufHFBheOdsS95ImPLkg2r0lScAPNs4OShhhsQQ+TwFzROOu4Z4JK3iD/rJ/zZiwbtxBk7QY2YRRetGIRc8ndwZAOkVYGgkycWVVuiED0WiUvxohkuaAS4u49xzMdo941P82v3tK32T+1pxNE0/Q0EkvpVUqCYQxL4m1R3s39zYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718198388; c=relaxed/simple; bh=xiTnCZU5KEL0H35TJi4MPR25pya4ueT1IUyePxAA0AA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AjZt4UTwMQJeyYcVPZUD6QYMeIv7W8FUs92TNdnE6cWsUpYt8eAYO2a3sRcXYZG/XnMGm0ARzhGwS76J0HlrXRiWCyM44tkXA7FzGkMolqzPzMCYpP57icoHV+/fKacRjbt0PL9t1mD6xMDxbmYaGmJI3V2/4O+UiN2BlQzedeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=c2txolqs; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="c2txolqs" 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 Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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++; }