Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp479222lqp; Tue, 11 Jun 2024 09:45:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+ufCctGHGYB5i+6CdT8agvv3ZqL+WwYCVD4hcUdZwGSpp+5VaCvewa58tLu24F9TuTPgTNv9i84BTHpQVB3YRzOCPWT3YnmwVqbmfvQ== X-Google-Smtp-Source: AGHT+IHcAnU8bQsOxX0NtKxuUCUeDGUOkJWsVDR3TO7pMLnCDyIqaQAwO+2EONmZjX9h0SxgCi1j X-Received: by 2002:a05:6808:bca:b0:3d2:2305:7227 with SMTP id 5614622812f47-3d223057373mr9889008b6e.50.1718124340858; Tue, 11 Jun 2024 09:45:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718124340; cv=pass; d=google.com; s=arc-20160816; b=KdKPJ4txxopyjnnTCrwhmNcTDijr2+hIovM+KQdmEiZA+A8AD3Tas/ce4sRcFFMQ8Q 03IeOyt0Uf3NyRKksaqu0Ul2ZyQVDYNWfVAPFuN/0Vq8Kt8SieFJCxfpDfRfArTzmWlS eePbuLZmlk1vnj6YIXeSWWNTvRf5QxldeODzzxYCp9Ipx+YIQkaTrHHIzPvnJBmJXYD2 TqHdLqiIjUOLBaj0Olf12686KXfASTWeC5BbkNK7Yx/qt/SPPQ/prb/WEP6GkKjbO9Tl Ob41xAZoyCAyJjDpWc1QHwAGCI7BeQRelDS+09eOgtYZxMVsh/IDCT2RIAnl03rQin5W rAfQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Gxh4vIrmKNIXaNnO4GUj7kMvMIp/Jmb4kSQsyNNbs0M=; fh=/a9w03MuJ2rpuT8Ce5+fEiDufLfn/bE73IpnqMQJmdU=; b=AdrUfvNqsmpk48D4hT0tEcP5ru/YKbaZO8vtXFprEIovkL3Nf5nTxY99ca4j52Iiz/ wJ4LbedXE4EsMeKbbrl3oslUZEDP3tMru19av9oB47KeDr0TuqT12sZUaFb/wHOmxscq apXI9kej0q2pK8fpif93YL3ZFKwjaESvIrgyZniRgkg+/r47W397PG4auemBphkLGvtc H8gg6b+NZDb9ceR4GL+QjcHoMtmf2dTGCrsZv7/SB7z64gx/eLv0wxrL6LdfIOtDhVuV VYFsAgTSzKBzrld9/ufEkrSZfc8tJjZSkCii8qpBAL9vip10+WikoiRC7CiLv2dXjjWn GKbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LdKcmH8O; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-210264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a1e0cc1a2514c-80b96b6e4b4si1448806241.202.2024.06.11.09.45.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 09:45:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LdKcmH8O; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-210264-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BC211C237B2 for ; Tue, 11 Jun 2024 16:45:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 893EF41C73; Tue, 11 Jun 2024 16:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LdKcmH8O" Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9E5D17578 for ; Tue, 11 Jun 2024 16:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718124334; cv=none; b=OXduKt1QsRef0+Twr6OkcetWxyAfjZtKlSO/EbgIXz2BVUAlEtsGL2v6MxU6+GcRRNEzCu8Yv2LFPxKoIjtVnAEpDqgCRYbH6BDgEUvAIYBGYRdadRuFgg0EOQDwDeAHghH76PnuNQu5LsWeQsQc83OLaDHZ8I7h290ZKKurzkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718124334; c=relaxed/simple; bh=2Bh/7FdcoRKuZHm/1cMaXHw/SlFeSlV4+dQAjyZVxpM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PAlJp7r5c9Ab4W41cLN9YmMHuwS7Evkc+jtGtbanB9f2xuQG1rp8CMHCWMueQefpQe3zEpZl8MMmuBWPJsEf80HeaaRdQuuHXQVTOnLB8YYSp+dNCPe6hvaOZ+vwt8tLuucoLfPpptt94LLPzCcmJhk9mKV8+hC670w/zmo/t3M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LdKcmH8O; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-681ad26f4a5so862814a12.2 for ; Tue, 11 Jun 2024 09:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718124331; x=1718729131; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Gxh4vIrmKNIXaNnO4GUj7kMvMIp/Jmb4kSQsyNNbs0M=; b=LdKcmH8OvcA0Uho2MDCQY/rgzCyhtcueR3v2nQSB8ZHBOyoog4bUUknYUWihcf2D3t TYu2CmREqd8x3+kYl3TqQH91TexyQw3jXEY3o6SARyS/SyqwvxdOkhmQ4ig3h8jNOKtJ 4G4YhF1Lndbd7913iqghAZ5iRaEQ/BHVPLKF9W1gna16nIC2GEs12jFXXInlMcOU37Gc 59G1//WcA7/XrVP/k9d4adwiS0L8yWnQzbIJU5/z8hfnTgV50/d1AW9XV0EFcmoiT8ib D/3X/ynPy/JfybeVMo2p//IQoEufPkpTOoSTT0NW8C4E+hwL7yN4toy1vm7PpAClyyrW 48+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718124331; x=1718729131; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Gxh4vIrmKNIXaNnO4GUj7kMvMIp/Jmb4kSQsyNNbs0M=; b=MsHSwVaMXTcZ9DYGR0meZcGlOiTNT0hQQtjz/jvmWvfQbfZ7xhjU6o0nQI8ZYnNu7u DVBCF3SQ3d8dbS8w4PmtO39Vq9zZO8nA8NU7VRMV+HPpuoTi/cIcrr/HQHzftpEbaNx7 TCKQmY7Jmb/dthpETrHZDspKMRRv2KvI7yDUvlYlwMs4ULlNsBLEc5VfmA16VKNy71XP 20QrrdYxHJdtTJjtwpQmdHGIQW2wUgD5m+tB02wy11m/89wGajuv0GR9C4b5rNpp31Sa JuwNsLx5KF2MHz3PoB5pDxOuYnG+n6ef/7Q4mRpk0Pz+WPGkCwGnzC5T+2UGE+uRK+mA ARCQ== X-Forwarded-Encrypted: i=1; AJvYcCVV8j9UuN5LhifYrG7il10QGZ6Za31/+oihRfOQXpHhTX9Am+cTDuNhHv1UfN+3fX6BAAJyUhLfwOU11/f5eGk2B7E5wKw2Y46miTiW X-Gm-Message-State: AOJu0YzLSd595iwdf/bwyPyhcpLTBZvYuTWE2NRhOVOU+F/vXHEAAZ0X KfV5F8ikCVlhdphEfXb1QT67eAwEmLP0fTJWlrW8/4B40+6bGaXHDvCEwSiPImc= X-Received: by 2002:a17:90a:d588:b0:2c1:ea2e:20b2 with SMTP id 98e67ed59e1d1-2c2bcc6c9ddmr11095209a91.30.1718124331202; Tue, 11 Jun 2024 09:45:31 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:74af:2f2d:5f50:e6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c32ba3d59fsm2219845a91.25.2024.06.11.09.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 09:45:30 -0700 (PDT) Date: Tue, 11 Jun 2024 10:45:27 -0600 From: Mathieu Poirier To: Fedor Pchelkin Cc: Aleksandr Mishin , imx@lists.linux.dev, lvc-project@linuxtesting.org, Shawn Guo , Bjorn Andersson , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Oleksij Rempel , Pengutronix Kernel Team , Fabio Estevam , Sascha Hauer , linux-arm-kernel@lists.infradead.org, Peng Fan Subject: Re: [lvc-project] [PATCH] remoteproc: imx_rproc: Adjust phandle parsing issue while remapping optional addresses in imx_rproc_addr_init() Message-ID: References: <20240606075204.12354-1-amishin@t-argos.ru> <20240610-4fb504648421659114538a50-pchelkin@ispras.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240610-4fb504648421659114538a50-pchelkin@ispras.ru> On Mon, Jun 10, 2024 at 08:36:19PM +0300, Fedor Pchelkin wrote: > On Mon, 10. Jun 10:47, Mathieu Poirier wrote: > > On Thu, Jun 06, 2024 at 10:52:04AM +0300, Aleksandr Mishin wrote: > > > 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) > > > > You're missing an "of_node_put()" before continuing. > > > > The node is NULL in this case so of_node_put() is not needed..? Oh yeah, doing a of_node_put() with a NULL value is are really good idea... I will pickup this patch. > > Btw, there is a "rsc-table" node->name check in the the end of the loop > body. It was added recently with commit 5e4c1243071d ("remoteproc: > imx_rproc: support remote cores booted before Linux Kernel"). Seems to me > it forgot that of_node_put() is called way before that. > I agree. > Also commit 61afafe8b938 ("remoteproc: imx_rproc: Fix refcount leak in > imx_rproc_addr_init") was dealing with the last of_node_put() call here > but it's still not in the right place I'd say. > You mean becaue of node->name being used after the last of_node_put() or is there something else? Aleksandr - Can you send another patch for the above? Thanks, Mathieu > > > + continue; > > > /* Not map vdevbuffer, vdevring region */ > > > if (!strncmp(node->name, "vdev", strlen("vdev"))) { > > > of_node_put(node); > > > -- > > > 2.30.2 > > > > > >