Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp436510lqp; Wed, 12 Jun 2024 06:19:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbocQPFiGKjM3e6yFEXKSip//Qf0Gg4UvqgKB6SiTsLmLkbHY1JD5f3j5/RTXbhTYke5c9lyY7s3e8q8lS2s5yiOzgBi2jIar2m/79jw== X-Google-Smtp-Source: AGHT+IEFitQ0MH9h+z067MuWC3P5VqD+LB1QD0O1y+ZIgrjI+UjZaqhnIVlA7ZDrZ2Q69/vGZA33 X-Received: by 2002:a05:6a00:13a1:b0:705:bc69:3860 with SMTP id d2e1a72fcca58-705bccfe0c8mr2591842b3a.0.1718198394164; Wed, 12 Jun 2024 06:19:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718198394; cv=pass; d=google.com; s=arc-20160816; b=hNY6l4bzvvYlR4Kc5hf4tHz3+1oggY5+cKnm5UX/1sCVl8zUsyAU3d4xAxMJBjzOxr uq4pxdyCi9jxEdqZOL0H+QY5Db30rJdS0Lzh9olK7FDkkD9d2REer1Nd/q9TG3zy4G5U l3pqC1ccIuegfmNY5MfMUfa4vXHHhu2SvbRpWoBwnKVsSA9RnVDXB3DGYuyqzA4gkemh GtyWQ518ERQoMmiHFcJ1nOqXvO3mJr26OX2aRNzRJhQcj/HdBJRv6slImOqrcGnIxJWY FcUYqDSG6Lh6hHEqO/S5G4jXYcT9lFqGwa2fJKjkXyEHN6RR5sXIBGE8529chVYAdJaZ 5A9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=sHLWV/zF6E7dCy7EgzBUyyoPsCq43FjnuXPUVgA9yfY=; fh=qfSKVLCxyvxbAXCJb3Tvkg9heUV1/NZhFRTtMHupij8=; b=KQiSxhOxeVcJmpi7FdMhEtkcasPQjRPWmeALKPw4KVM4Puk0w8gNXAkctPf1H97T2D apN3KfBUPRGQvMFELyY7hIpbEOcJv4ep+W87iG5M29G7DyAti8ceTygWLOBq8HaF/fll Xz3lDNtWxpHTOiD61xV/kD6Qqy/v1kTg3nRKBwTaALX8pOCgO2R+SETFEpSmYMmdh4df jL+Dn63wKSS5Uujd/rR5UxU8gT1Fe+t0aofEHXEw6N0rY5dly9UVuHmhx2+AmxgAuKRo o89Xplp8Fvqr64fh0kz7o0risrlv7g7DOHiSqKXYAgmoVlejnAi1AVHVbhEYl9Ur/VOO QaYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=c2txolqs; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-211547-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211547-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e39ef4e555si7638453a12.200.2024.06.12.06.19.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 06:19:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211547-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=c2txolqs; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-211547-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211547-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BB79F28367E for ; Wed, 12 Jun 2024 13:19:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38B0617B408; Wed, 12 Jun 2024 13:19:49 +0000 (UTC) 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 (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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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++; } -- 2.30.2