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 CA190C27C5E for ; Mon, 10 Jun 2024 16:47:37 +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=YHW1gaZ7TeMQkUm5I/nUJUmFLnjoasI6emr/3H+TWN8=; b=i11tRuqf6wm93V xUvbXv3CnU80pLxDw28r5oyGPyWWo7FpO5lsVCAbITC81b5ngSPUU9QXE76LG4NcJyJMK6k392fqj nU+WbiJ1Z3lowyZed9UjNuyeZHA7KOwL1ihfXDqd+r7VW+X+k281MqAr58N1gkYgdwGpyReSXIVHT UMdDCieGyFLkbUV/ZI1Bg9hS2AXIOiuH5yopH74I9+Zcty7bFV9sM8FfrFItD9L2kB6gv/+9oxtvw /ly3MXfuiIKVRU4cV9Px0B4SiZEibHxNOw1zSUZlJcNOH0OBTHP4N4u9hdmpFzBDIOvhoC9/MJbXm lPwjuZRx2O8r1wbRk/kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGiB3-00000005rnk-1qR3; Mon, 10 Jun 2024 16:47:25 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGiB1-00000005rmR-0vlU for linux-arm-kernel@lists.infradead.org; Mon, 10 Jun 2024 16:47:24 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-70435f4c330so122733b3a.1 for ; Mon, 10 Jun 2024 09:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718038041; x=1718642841; 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=GltpCEOROqdEZtPzqZDYIjfn931I+xP8uUPheSuWph8=; b=g4VZAtcVNmeF2Ka+XTDYBHC9NgwCw4OhYHrcp0GGgg3j8G3H6+oV3ZY4LIJNvaG5c7 nkxGrnVO2fOZ1HJfa1quyUTb7N6BFAPX5Yo8wppj5cwBwCirkae9nyYLRE2rRXn4URQL 2AGjlIYzQpomQGXl/qLeN3aZBf7HMJjfc2IrX5S30kaan5Y9ekoh1gFadLRCr0BZqBnQ XyOAZh2/un30OPMWIXgpt+QHQNgEZ+PlDwjB0ngQjg/EqVoTyoTByv2zqke26H1oHDDJ f90810iRWruXZJIfK74pgoX82fA5kJw+Pn6iSF9/Fm8q0fLtS3hzin38peC3TSK5spfh GPtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718038041; x=1718642841; 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=GltpCEOROqdEZtPzqZDYIjfn931I+xP8uUPheSuWph8=; b=RJShLq7c+1TNvKpb2Yk7Aogix/0PNPPaZ0REYaiMMC2vw86Z8fNDengGRv3wqX1MPZ j4rd5+jb9/xeD+/+akpnCxk7VjGP558qJg7EktdKUrwuXYyP9rpAAiEPYkLC8Izk9jX4 BS6xS1zvApF14KlJeTLG/mIgHBclinpiGWRmRiNJZY90YoqD00BFaket3IVdPObizQqK Ah7y879LzRhNA0da9UpCZPUk3Dj8RRNO6nx2fR7cipfwrOKbqBOD8Xo6ROIPJV1OY10z EEc5UPA33b4gXjmy3Gcc+ao6islqvDXpQVHcQ4bVFBIHVFs301SBl91kdV0K6XKv15BI XuUw== X-Forwarded-Encrypted: i=1; AJvYcCUI6BiqY7ebK90LD+NtLrjZmwSZ8d3BshZhLCiNFoiw1a72vk72cpoGn8y6X2Ho8ENpFt/nLcQk5MJ6kFlzHU8euCCM58LsbU66y7akMGVMY1TQGAs= X-Gm-Message-State: AOJu0Yz8XtpCkXqtHxEgIPkPMRIOBC3fCUpvUrDLc20d7tWwe+IDH9YW 720WnOZ+PVU69ySyFPsHvCfHfXirRIn4KyMob9hp8qMOnXmGpxPmjymwn9IDbGM= X-Google-Smtp-Source: AGHT+IGb/lXCCC+JbIDGUdr375qb0RgEL7LsqGDkkx+quxB1SnI5zlcCI8SeIz3Y9Zc+WyklRsuyOQ== X-Received: by 2002:a05:6a00:8506:b0:704:25de:f297 with SMTP id d2e1a72fcca58-70425def3f2mr4676511b3a.29.1718038041356; Mon, 10 Jun 2024 09:47:21 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:9b34:fecc:a6c:e2bc]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70426cc74f3sm4045691b3a.35.2024.06.10.09.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:47:20 -0700 (PDT) Date: Mon, 10 Jun 2024 10:47:17 -0600 From: Mathieu Poirier To: Aleksandr Mishin Cc: Oleksij Rempel , Bjorn Andersson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , linux-remoteproc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240606075204.12354-1-amishin@t-argos.ru> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240610_094723_635269_0563C515 X-CRM114-Status: GOOD ( 16.82 ) 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 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. > + 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