From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A376FC27C65 for ; Tue, 11 Jun 2024 16:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xio2FSh83ZJnwt/u0e4pKGBCXIKahH42xGSM1Paa2gQ=; b=1eNolak6300Z0z 1Zk19IZHQMP8BevvCANUeyAvuXE0UeN4QN6Te9cpysDsDvokTnBvY9tKdbS/SIFzz1jCEaUmmebuh pJkUmccef+GcFsLA1TCzPVI9tOUtvCyz5CwDAFB8rUNtYVBPXW8IKa89m9oY/PlYrI69IbmeckJ8D mrpHksqlCrgBEtOogimBWia8TAo5REQJZ1Q9iGJKnJq633h2sRMtj4wKZijYLkUMv73jjM/fAynVO g1Oc1vIxnoRcJXUsAJpPzBdrQleXwgJxqiKGVvdB8sIwkMYLkVhMyKzNU6NjrdMNq2WXko8vCnnVA YajMHimerhQGSCUgVxtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH4d4-00000009YGC-2ZRg; Tue, 11 Jun 2024 16:45:50 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sH4cr-00000009YCz-4Aqm for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 16:45:47 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-6e54287a719so1008525a12.1 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=lists.infradead.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=TY5xoYw0/i4+WAN0UTL2ni7hBiMDTVvEvx1lrmRKCm+ZALdF12MQxnRkdzHdeN9RWc ZIvJYzvJ3ww+DDy4SC0V+vLyLCTWLHFLQ52VHvwGEIDAZFD/3v0SMID7LhPajfW7XKR9 F1Bh9+Qy5fWPZxUC779MahpwqaD7p3F3NIcncHcnyteBIfS40b7ilNdnOe/2bt9AjH/x YDnjvsGaZNBRGwGojeQcJF4ogoL2RolZHQXtn0C7idNZKlhKmOTKzGL4Op+rsC/NF23z hL6h5Nx5p1EexaYfb2VPWrBP4w1aMFER4UOkeFBunjplgGtyhEDhLvu8riD3uwTofdqV p+sw== 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=uP7MmohOrNeblOOO4+aRZYWwAso7TXt8B3oIPiUrHPwO3wKJGIf+t2DuwbIjJNchEn tF6xhINuj/xX57TfXkbPrvbM7jB6HCDkdKmq0Yify3HwtezbSARtyBNw6dqCLn1dGxcc Iquv4Eej31WzrddyPtZFXtApeVxq72zdlebYeA5/FyAHA2N8IsaOz5+gGrP14zasUtVs v/QIlVdH9HOEE7r26PlPyuvhtp496Dv/OFYDi79+LsV02dY/nps/CnHIevqqX+tPgBhe rDyDUMEKxNFJXhRgrTdZz/8cBiNvQ+eD040WT6CViosZ8ivS2L0hz+t+Dt5RtNbNmCMZ m80A== X-Forwarded-Encrypted: i=1; AJvYcCUhWjJMVWyPGWt4Zi5QNFSouOW1BOJMsnXAngyAQPZDQMJpDuz39RFAxU1Yf3RWRR9c3cJtyiFKuZb7tAFRjJ42R28KKBL6M5zIwje5boZdqdJfueY= X-Gm-Message-State: AOJu0YxA2Dnuvw4sJsSr/XQ+zqsoUwP5q0XNF0G4LzcFT196DKcmd4si 8C/4+8DyShpAiGfCejk3/rCtrVu2Q8SDCiJQVrU4YGxx2uXFXiZDYz6cMQu/Hcw= X-Google-Smtp-Source: AGHT+IH+FSYIcHzGX5O1UrgkGqxESmaE4sfiuSdN7cxUsK+Rn4rESv7cVAMHJ/TaGzdgKg0Ddd7uUA== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240610-4fb504648421659114538a50-pchelkin@ispras.ru> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_094541_902358_418F9F11 X-CRM114-Status: GOOD ( 26.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > > > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel