Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp1537488qtg; Tue, 21 Mar 2023 14:33:42 -0700 (PDT) X-Google-Smtp-Source: AK7set+/r36Je238OhoIoKxHIYvUg7xsmz3pad76OmLfsIo3kuS3PI4wd+XqUzt4etZ29me2Pgbz X-Received: by 2002:a05:6a20:7f8c:b0:da:4b41:8606 with SMTP id d12-20020a056a207f8c00b000da4b418606mr3992691pzj.5.1679434422645; Tue, 21 Mar 2023 14:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679434422; cv=none; d=google.com; s=arc-20160816; b=uC8GggfSBQp+feWKJxxy5CvOd9Ao6yB5CAcnvny4hrYuKPAXDvI+NfIZzrnCLNFBb8 1fgOMGQAJmKq9fqBf/XpF2g9F1bANXRT3Kg0Ly9oHp+thi28TiW5HJegYrNa4iuoTAD4 RG17xTb0W+pOHqDEwiTs9TVNym3TeDD7Z2ZEVSLd0bJPPU+nTaXJwm96XBCNY3BmpZ2B 07gwqVS5gH2JJKGj2bciDjtYxAVN9+NHjsCKO/5JzmhmZxtYvukPAKtdik/quCRNT5iI 497S/9h0o+C9UBiSmsuRYfaRxlqe3cpBHxi78HY0pxPEcpPtvFYs+6v+Z4pt1Ur3nPah dAAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZzHxTn/xBhnpdgy8S5E8M4unosxnUcsaF4INeWuGSNM=; b=VTgPatt4nDC3TJ67V0w3cjOIjbwDUuf0PgI+Wxvc4Kv4E1U31y3zLw7Qu7ZGtkZWTD PzWNiMXPib/ux7y4xgd1jGZmpZSI2y8oRzB72ms5MWGz4D3DA6aRNpzlxK8JX/QrsIvF nWfD8A69Xxg7GfJXW3AEuhfgqzx9sXGjCRgqOsaE2lGRn+4nMw8d28gCYW/hK8TmamJN Ois5sz/GfoccCR6ZUEGheiYNEEmneNIUgdI4311ucE38MXey0dPb4ccvx5dQR3NIMsBv tOiklZs2SAcSF5gfeYfFONVzlxhw6uDEU/3zlRxJpD9xFZOkTvdWN0FYrWZNLOy2wAcd CN0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kxyTO4v7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b0050fa589bc9esi3215212pgq.592.2023.03.21.14.33.28; Tue, 21 Mar 2023 14:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kxyTO4v7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbjCUVc6 (ORCPT + 99 others); Tue, 21 Mar 2023 17:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjCUVc4 (ORCPT ); Tue, 21 Mar 2023 17:32:56 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2FDA58485 for ; Tue, 21 Mar 2023 14:32:53 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id w4so9394998plg.9 for ; Tue, 21 Mar 2023 14:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679434373; 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=ZzHxTn/xBhnpdgy8S5E8M4unosxnUcsaF4INeWuGSNM=; b=kxyTO4v7cC+7AJfDMMODMO/Ytb5E95ibpucDviLwkUuXDhCSN5gCydR3ahhruangOc DViOKaJQUNBhP5v1Um9hVcsrbGIMno2OjwUCKR3JEYx4LGJJ8eT1OoeVbibpgjS4zsnR vMPaHiyBlZ3YEAx4buv3XVKaY6lYABPmnMxxt/x2ZB9D2hAxPjs8ZkPInbfN6ShFXmlO Q2d56ojjw2xhKUcppHYjGNUrOu1ehGvSv9rll3kccRJG1XY5PNZD3/xG7W7o8UPF8Xs2 UxiyQ+9As6JD7CUVqEMWGViPRwjg4geklBa0yu2evkg8aKC9nIvlYxDN8TJUDPN1iyFL YTOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679434373; 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=ZzHxTn/xBhnpdgy8S5E8M4unosxnUcsaF4INeWuGSNM=; b=4CFFj63S8osn4l9oFZfpJyAWD36+G9kuf6GvkKeqmFQmmHRiGo6HI6RjZHNhFRgk6z eQNuYTTjlvLWLnW8J/aLcGSo9IzYt3TdoyHDn12Hpv3YKQjC7iEOiWLcQW0esG3NOpJA n+/+TCioftntGnSBzxBZ261GDMYC5e26pOosLlJqM/fNT2w6OuBfyO+SbC6VD8mYVoxv rbPofgPOsuIZ/yRG0rvGMcC3Ni6o+M74SV29iywPJ4om/LTmBBcUQLIYRslvO5QFzbdN 7w1EQQtS6NMYf5ZbxTENvb2SzfiZqEKM5bHRyVN5anfUMA1e0wYXBmq7ZzQR5vUrt7LQ lStw== X-Gm-Message-State: AO0yUKWA/LdtESFih+IT+ljN1qHm9DX1cKP4eyCMBq7jsS/E41W7IJz+ xopInK23BJADSP/KLzZFQiItYw== X-Received: by 2002:a05:6a20:dc9d:b0:da:f525:e629 with SMTP id ky29-20020a056a20dc9d00b000daf525e629mr1939980pzb.53.1679434373294; Tue, 21 Mar 2023 14:32:53 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:8a45:c131:e8ed:3f53]) by smtp.gmail.com with ESMTPSA id n1-20020aa78a41000000b0062604b7552fsm8728060pfa.63.2023.03.21.14.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 14:32:52 -0700 (PDT) Date: Tue, 21 Mar 2023 15:32:50 -0600 From: Mathieu Poirier To: Arnaud POULIQUEN Cc: andersson@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, patrice.chotard@foss.st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, arnaud.pouliquen@st.com, hongxing.zhu@nxp.com, peng.fan@nxp.com, shengjiu.wang@nxp.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] remoteproc: stm32: Call of_node_put() on iteration error Message-ID: <20230321213250.GB2782856@p14s> References: <20230320221826.2728078-1-mathieu.poirier@linaro.org> <20230320221826.2728078-2-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 21, 2023 at 10:00:03AM +0100, Arnaud POULIQUEN wrote: > Hi Mathieu, > > On 3/20/23 23:18, Mathieu Poirier wrote: > > Function of_phandle_iterator_next() calls of_node_put() on the last > > device_node it iterated over, but when the loop exits prematurely it has > > to be called explicitly> > > Fixes: 13140de09cc2 ("remoteproc: stm32: add an ST stm32_rproc driver") > > Cc: stable@vger.kernel.org > > Signed-off-by: Mathieu Poirier > > --- > > drivers/remoteproc/stm32_rproc.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c > > index 7d782ed9e589..23c1690b8d73 100644 > > --- a/drivers/remoteproc/stm32_rproc.c > > +++ b/drivers/remoteproc/stm32_rproc.c > > @@ -223,11 +223,13 @@ static int stm32_rproc_prepare(struct rproc *rproc) > > while (of_phandle_iterator_next(&it) == 0) { > > rmem = of_reserved_mem_lookup(it.node); > > if (!rmem) { > > + of_node_put(it.node); > > dev_err(dev, "unable to acquire memory-region\n"); > > return -EINVAL; > > } > > > > if (stm32_rproc_pa_to_da(rproc, rmem->base, &da) < 0) { > > + of_node_put(it.node); > > dev_err(dev, "memory region not valid %pa\n", > > &rmem->base); > > return -EINVAL; > > @@ -254,8 +256,10 @@ static int stm32_rproc_prepare(struct rproc *rproc) > > it.node->name); > > } > > > > - if (!mem) > > + if (!mem) { > > + of_node_put(it.node); > > return -ENOMEM; > > + } > > Good catch! > > Looking in code I don't see that we call of_node_put() when we release the > carveouts. > Please tell me if I'm wrong but look to me that we should also call of_node_put() > in mem->release() op, in drivers. > Are you referring to entry->release(), which for stm32 is stm32_rproc_mem_release(), in rproc_resource_cleanup()? If so then no, it is not needed since of_phandle_iterator_next() calls of_node_put() on the previous device_node with each iteration. Otherwise I fail to understand the question and will ask you to clarify. > This one remains valid. > reviewed-by: Arnaud Pouliquen > Ok > Thanks, > Arnaud > > > > > > rproc_add_carveout(rproc, mem); > > index++;