From patchwork Mon Mar 20 22:18:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 13181973 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 57D59C6FD1C for ; Mon, 20 Mar 2023 22:20:10 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EyPG6LogHK42T7yS1LiOKENeScFzc4kCd1qa9UWWP14=; b=LOBGZFIhiJBA6Z V1k5XbCLdpwEe8yT8Hd6DFbN3XLP39/QbsaVFXlfsOnQZJNUX9cgt1mhMjN4OPiErnzPvCT4wLWDk K50aoY2pCe3hBkBkc8A3O8JtfnvgZUlVfObytKZ4VxXSirCE/45g+uj40QdgFcwEqKA08PGdSVkLi ZHGH468EXYvCOoqzqNNjHoE4W4vWu5JiwRf3GZzxYqfS5PTOIYpV7migpFatF/p3yOw+AaXTDd+ap m466yf7kbCjdvJ+uP0pVNyx3V0Y6Xvxs/8rSwmh+DCtBDD89mMUUC+YMQ/0A7BbqM0UCZgdOM5CKd /ALHy0L3tr2C55PnA+uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peNqU-00AdSU-1J; Mon, 20 Mar 2023 22:19:14 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peNq2-00Ad8q-2o for linux-arm-kernel@bombadil.infradead.org; Mon, 20 Mar 2023 22:18:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=s/LgoSGK+GmE6/EU93H8+NXO4ccsf9u+CovKfDKWumc=; b=kHoYftMlo4up8OtA2ZbIG4IaHd wAxp8B4myuY6Wzq1ro6I7H0sdsOjY/mmmz8xYUu8srbWW5xYvkYnK+GgdeFmLCob8XrIUqnl7qhko YVZyd1+wW0DjSD+lVXrYssVasjvuXsTLhpGYYkoHSy0dGKwtrZjIDoBciPcbR2ti2i0U3B5Gy2DYf WDkkSuTCKIdI8JnNUNu6xNQGtJSWg6fq8lreXUHCs5klXC0UKOVqeeOfYjBsBJ7WlmwiTVPwMix8g jqNf8eaITXOkecl71d0uP6paxFfnF82DxFmCfvJ9YUThcewIEsj+b32A3Llcs/YjFsOGrzMG0Z9YO z+OEgpxQ==; Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1peNpx-0044rg-36 for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 22:18:44 +0000 Received: by mail-pg1-x52a.google.com with SMTP id bn14so59250pgb.11 for ; Mon, 20 Mar 2023 15:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679350717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s/LgoSGK+GmE6/EU93H8+NXO4ccsf9u+CovKfDKWumc=; b=Juoyvhyhe4EVorBJbKfJG5cW+0Su9a6XcIbbfOnxvZcr96R7XCEUjwKzp651fA4P3B xQTMyT2BESSeUn79Pnqz6OzC9LUrZzUtdLXqACH4HLqOKxrIL2/NZdJvjGJGXpsLtYAE nw/AVLyzWI6JfiCXqm/EczR9AWvVtpUC9CXwXegc3rAI8RNdOTls4xpkQza4+o/no/6Y 7hr3Fti1zNNrz37wUl546X8sx1IB46mbLF2BrQqeqPEYcwljyanNJ2xpNTqfBtIq2KtA bFHJc5KVtP416bgv6YlM5DHuQ600W/290Wiq5+8gdOH8t14XYl3jAr9ENimoM/Yo8Xgd DXyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679350717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s/LgoSGK+GmE6/EU93H8+NXO4ccsf9u+CovKfDKWumc=; b=aFlhG7I3hiZFUHLSOoBsnJ9oHngPoZtSAv71PIBAC4jeFK5+sLK4IV0WeY695fIC+r Uq08r9DkN/8c2UO18EAIkfqBT1ZmYBTaPVnUZDs9Y+RxSXHdNgdUaohjftn8DdiH6+ld CcGilpD6qhDcm2fFzfLS0e3Qaa7LyZmGo0Wt7qkteqmZRmc4W5Fn/aRcQ8DVd56lzzB4 /iq9XRznW4HtFPxXFIjDqFnCsk7xnwyvxpsQYDr+7gJgNOjo2uor2/HXLUwcE2oL6oBn 3uw2XlBAJNNzRnWwkd6XTA/r/7gsavAItobwIMTAAPCh32tAif/PH+3TeDozda+dJ9U+ /L9w== X-Gm-Message-State: AO0yUKWM5JeSR3QGx1v3WFNfh3fA6O7zNBibu5oib0zzfCQeo7yome/E /iVq8FkKaVg52jzDiOk9KpE9SA== X-Google-Smtp-Source: AK7set9KHdWfT5WQ73Y09ku7vZjlXSifntdEtuo1i/gz6GfDAugJDKSdSdauloxms2X4Yf1Bm9z7HQ== X-Received: by 2002:a62:7910:0:b0:625:d630:4e1b with SMTP id u16-20020a627910000000b00625d6304e1bmr293831pfc.31.1679350717432; Mon, 20 Mar 2023 15:18:37 -0700 (PDT) Received: from p14s.cg.shawcable.net ([2604:3d09:148c:c800:4ab5:5131:bafc:4428]) by smtp.gmail.com with ESMTPSA id e15-20020a62aa0f000000b006259e883ee9sm4459196pff.189.2023.03.20.15.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 15:18:36 -0700 (PDT) From: Mathieu Poirier To: andersson@kernel.org Cc: 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: [PATCH 5/5] retmoteproc: imx_dsp_rproc: Call of_node_put() on iteration error Date: Mon, 20 Mar 2023 16:18:26 -0600 Message-Id: <20230320221826.2728078-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230320221826.2728078-1-mathieu.poirier@linaro.org> References: <20230320221826.2728078-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230320_221842_380467_04D0E8BC X-CRM114-Status: GOOD ( 11.95 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: ec0e5549f358 ("remoteproc: imx_dsp_rproc: Add remoteproc driver for DSP on i.MX") Cc: stable@vger.kernel.org Signed-off-by: Mathieu Poirier Acked-by: Shengjiu Wang --- drivers/remoteproc/imx_dsp_rproc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c index b8f268d41773..21759d9e5b7b 100644 --- a/drivers/remoteproc/imx_dsp_rproc.c +++ b/drivers/remoteproc/imx_dsp_rproc.c @@ -650,15 +650,19 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv) 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 (imx_dsp_rproc_sys_to_da(priv, rmem->base, rmem->size, &da)) + if (imx_dsp_rproc_sys_to_da(priv, rmem->base, rmem->size, &da)) { + of_node_put(it.node); return -EINVAL; + } cpu_addr = devm_ioremap_wc(dev, rmem->base, rmem->size); if (!cpu_addr) { + of_node_put(it.node); dev_err(dev, "failed to map memory %p\n", &rmem->base); return -ENOMEM; } @@ -667,10 +671,12 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv) mem = rproc_mem_entry_init(dev, (void __force *)cpu_addr, (dma_addr_t)rmem->base, rmem->size, da, NULL, NULL, it.node->name); - if (mem) + if (mem) { rproc_coredump_add_segment(rproc, da, rmem->size); - else + } else { + of_node_put(it.node); return -ENOMEM; + } rproc_add_carveout(rproc, mem); }