Received: by 2002:ab2:7114:0:b0:1fd:af6c:537a with SMTP id z20csp442804lql; Mon, 10 Jun 2024 10:37:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeWQ8F0frz7YGYAr1M80LN36mF42eoWiecQDnMbWvPvrB+SZpWm2mVPYJAVC2lIgFB2KbQ09aMHbBNOmLN1qkh3OIEOnJyzhTBVuXGbg== X-Google-Smtp-Source: AGHT+IHHnfEa5kpecTUVr3klrW7DywtTWgH4TiWkBFf2Ca7xwo0n/H2Ghd3BS0TEKwOf6yJVyZCk X-Received: by 2002:a50:c316:0:b0:57c:6d9a:9149 with SMTP id 4fb4d7f45d1cf-57c6d9a92demr3898538a12.15.1718041059332; Mon, 10 Jun 2024 10:37:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718041059; cv=pass; d=google.com; s=arc-20160816; b=aMa/YCP8gOV/96rIWjbTkzMQi4ee67dxLvcqdB+voekBlq81nYuWG0+xL15CODZCV3 K0KkFCs0BT9d9T/cuxeOni9ZxRYgtZKxCMIE6aYTgYw0t0vXVtyknYctch2A1loNeGZX JQFQyofefimOF24rLXxqRiphkEWHIvTiIwPKhUNg8DNoZ/eiwmE1Hw3oQpScrXB993yB DFfjhfvn1k53aVnzvGRpSDPUp8fLP0VvSGPnXwzYYXdeWqrPzS+0hXSzDqIz7eB9iavo 4Kv9lI3XTIdDZy4g2eEcLM2yMnibONtY5L/aTIiKKAF8GDvcSESV7ZdiqQ/RGHWrw/cX Ehjg== 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:dkim-filter; bh=3mx7J795/y8Yz1JHM3D8D7/9NeMSSgSBgbIlVoPD2Nw=; fh=Eot8s/y45xght4Qxvs45levy48t11W8ioQPYaA3N6V8=; b=F2NeZRWE/84Kts6GZw2GvmkU8sYGar6kow/LDgnC6cmKzg9KEY6eQ4B6DJqzm7yJYa 5D6fBp5GYRHenOtuYlGhzhftlhR0Nyr4mnU4eQaE0IlMjpxaLFssdx+9v95c/ACK8T6w n+r6mmFRRytJdTmH1rzDH08TTUzBfCOws3SbYJvKKfF7CtQMvISGUnTl3RBOkPLbrdIk phhH6nHxbdjs5lkdY1v64aUhWnVTeyeI693/BEUwvRaYBbrF/+orGxoO0rlAjhZuzdtl tfzf+MisfRt4zVDcWqVH7BturpZzucC4cIrEu9R8IpsW+isu7+VVixIeSWz3Hg/yppJj msVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=McdIVopN; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-208664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c6882d70esi3117203a12.378.2024.06.10.10.37.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 10:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=McdIVopN; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-208664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 090491F22EAA for ; Mon, 10 Jun 2024 17:37:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC03E14F13F; Mon, 10 Jun 2024 17:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="McdIVopN" Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D16414D6FF; Mon, 10 Jun 2024 17:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718041000; cv=none; b=Uae6FUHeRTsoraA9uZN0PgAipnSTR99B6Juw6CbNi7ZphG8GfZKQC6SZmVfr/h087QrJdTYwuB8XK4b6qjdwKOFblPY+2cyoDXnsuMnM8s+B2jPbaPtBDfEgIApXK0PMArLmTfJhAVljKZzp07bFRESx+3Ea7TyiNfgjxqOgf6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718041000; c=relaxed/simple; bh=5peT9yE4nDGFeJtvaJ7NLGE1KQp2YckJYIwOYXJbbGA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lP9zAeeV7jiRw00+qLVrlo+KI/TsqyNjMxFLOvLWGrpGzKo5l5pd2jDdM35l7GJ3UwbEBEg4MXfbaZiKzJZI/u44J0qfgdRp4iDoPAqgzcPbql5QVkuMAmhtEVkysPugZHx2QZ9tq1gDSD6EYXHtAQqdixbe2K35BcI99fwuG4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=McdIVopN; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Received: from fedor-21d0 (unknown [5.228.116.47]) by mail.ispras.ru (Postfix) with ESMTPSA id DF359407853A; Mon, 10 Jun 2024 17:36:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru DF359407853A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1718040987; bh=3mx7J795/y8Yz1JHM3D8D7/9NeMSSgSBgbIlVoPD2Nw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=McdIVopNHE9BRDrwTqPcWXIO+30y9qCb6noHwAH4dDKfyUbq9GDBLoR6aKWr8io2I BT2j8PVErELdSAd8Q0EivkajK22MF3Znv3dvy255z1Ge/lhT4EBPLvC3z3qzikrNI4 pGMDUX6mSsXL8Nfjm3WqLyyI5oB0K/q8lOoZvA8c= Date: Mon, 10 Jun 2024 20:36:19 +0300 From: Fedor Pchelkin To: Mathieu Poirier 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: <20240610-4fb504648421659114538a50-pchelkin@ispras.ru> References: <20240606075204.12354-1-amishin@t-argos.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=utf-8 Content-Disposition: inline In-Reply-To: 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..? 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. 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. > > + continue; > > /* Not map vdevbuffer, vdevring region */ > > if (!strncmp(node->name, "vdev", strlen("vdev"))) { > > of_node_put(node); > > -- > > 2.30.2 > > > >