Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp211228lqt; Thu, 6 Jun 2024 00:55:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXD89EXw30Z3iPXxJ4JiuoYY0Cu+d9/VNzSNxZZRlFcKt1MlQ86yTCc6m66kpjabybpBolXkwE7sANxLUWO0vIXbK3q6HVpj6g3BG3oDw== X-Google-Smtp-Source: AGHT+IHrJg1A19QYLYtQJwi3KivY4CehIfGZg198zS1Jmq8coox+Sf3PSw8dSICH7y4qwD598G5A X-Received: by 2002:a17:90a:ba83:b0:2c2:792c:b60f with SMTP id 98e67ed59e1d1-2c27db1166amr5015591a91.11.1717660530163; Thu, 06 Jun 2024 00:55:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717660530; cv=pass; d=google.com; s=arc-20160816; b=js/FBjIJVT5Axge0wNkUqMeDYkgF7bUodjDHlbw1/ibFbP6bNJBRVhiOGxZcRzTw5Y resoUmFi41iZ5QObFZFjhWUixJz6c13o7qUvfVNBwIpeqJ6IHXQ9ps+AnvrtL/du3RMt 8uTaGJcJfKDG1IHONYRzC7JYri4V0X6YwGy2GR6b6KQqydU7p8KrdQ6sx52JsQbTLHk2 JtBlh1MhviM7rSSiXSlUzwu+TB9foDNFq5FlaX/X8pJOjImOuNOJFIkyVxa2ykrgVbHm EBVpLFRVKlS1F1PKg68BkunhQRZHHDGaQgZDd12LoBfUJSa9HcQ/jakguHEF+3oq1jvv 88EA== 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=gW9ORV3gxogsqQE+vcvVzXZfgTh4/T9kCBioOXKDrlY=; fh=XfciTQdbabSnnNpC/hmBpYxrQCbIx2ZD7q0ZnF+F4lY=; b=TC5CWzdqpZQke6LjaELQ1ril3E3Es47Ls3rM1eflj25Tk9Smmj1wObFxWGu4Yb2IGr GsiLelBTPWQ3DEb6fREA5RqXplp0hIhu5iGpjbGEYAYTjw2+lVrt9F5e17r0EJu7uj+f aZ11SUbW9ZXtu/EGq6ev9UHcpgmbpMTCf/PtclPqYjOXb+aLtFgARVr9IaSZbnnrsaZH G/ABkEDg3J0jyh1SuYmf85DDc/bFBfaXufhxyv93q7GxAAGZwas8Q4QeIzyUZYVQJ+oX mLN6IuH8/PpcbOeg0nAQ+oN36dPLaMg4aGaN6/77+AZYPQL/C0OG3tNyJpvEvRai3Hcz t01w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=m5PdVe20; 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-203766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203766-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c29c219528si752885a91.51.2024.06.06.00.55.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:55:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=m5PdVe20; 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-203766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203766-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4EE6CB23932 for ; Thu, 6 Jun 2024 07:54:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 180A113BACE; Thu, 6 Jun 2024 07:54:08 +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="m5PdVe20" 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 4402029CE7; Thu, 6 Jun 2024 07:54:01 +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=1717660446; cv=none; b=M7eIK3fedq6IVOkdFHF0gErz3hVDNAeGwkFiHLmOSiAA00J3KniipBwgp6m+Bb2zUwarN1RiMTlIfm9vT08nP2vhVpAlTTVfRjF6Y1SmT83Wyftz8XW2rzQWON4E5wVBIpxJwkSc7TEB5IxUSRTU5ogHqwT4LnfuZWYklEhhDFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717660446; c=relaxed/simple; bh=0eHWKmq6DgAnQMopQxlhQQ+wYbXZJwu+2Rydq21zm1k=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=P5RfnKqGycJdbn0MBx4VdXGeX0T4ce9pbtNJVJsVDkt56qMB+80NrvqkC8jpF230hRvYnoodYZit20L4tVeCMNPl5RMMZ/xAUVhjLl1Mr5JdUXbpb/Di6ohhcYmsAE92M4vhtVyVkqV9PDd4Q5A/sVCYRwJ6Pe/w+J23IlkhwvA= 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=m5PdVe20; 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 33865100003; Thu, 6 Jun 2024 10:53:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1717660424; bh=gW9ORV3gxogsqQE+vcvVzXZfgTh4/T9kCBioOXKDrlY=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=m5PdVe20m4Zw/kujZC6//s+1uPdkKVN1h6go9RGX8BlU72Ai+5yFsiZYZyU9I8qrX TGta/kSpqk3ECZbwDjbvLALdWgVB8cxv47Ukjz7dyybNveuGtQKVR05etGEQ/bSDkM NPfHglajH96oyesvkoOmTkAmn6SjG9ydMuNy9LaYNmAQSrfq01ig6mWlFIKp+dbNw7 mfcL3cRp/wA1U3m4i7p4R1vYfMzRsVjPHlOeJFDPrrdZJu2Dm6pyqDgSHPOqyyimpU SvrQfb2w94RZ8D2tx9Qs3Vv5um/RpyfPeFiYrr7uos/QoxXlpqu4mdiTn42/Q82DDM mu37CMDR03nfA== 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; Thu, 6 Jun 2024 10:52:32 +0300 (MSK) Received: from localhost.localdomain (172.17.215.6) 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; Thu, 6 Jun 2024 10:52:11 +0300 From: Aleksandr Mishin To: Oleksij Rempel CC: Aleksandr Mishin , Bjorn Andersson , Mathieu Poirier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , , , , , Subject: [PATCH] remoteproc: imx_rproc: Adjust phandle parsing issue while remapping optional addresses in imx_rproc_addr_init() Date: Thu, 6 Jun 2024 10:52:04 +0300 Message-ID: <20240606075204.12354-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: 185754 [Jun 06 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}, mx1.t-argos.ru.ru:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;t-argos.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/06 06:52:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/06/05 22:40:00 #25473187 X-KSMG-AntiVirus-Status: Clean, skipped In imx_rproc_addr_init() "nph = of_count_phandle_with_args()" just counts number of phandles. But phandles may be empty. So of_parse_phandle() in the parsing loop (0 < a < nph) may return NULL which is later dereferenced. Adjust this issue by adding NULL-return check. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver") Signed-off-by: Aleksandr Mishin --- drivers/remoteproc/imx_rproc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 5a3fb902acc9..39eacd90af14 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -726,6 +726,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, struct resource res; node = of_parse_phandle(np, "memory-region", a); + if (!node) + continue; /* Not map vdevbuffer, vdevring region */ if (!strncmp(node->name, "vdev", strlen("vdev"))) { of_node_put(node); -- 2.30.2