From patchwork Mon Mar 20 22:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 72514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1474483wrt; Mon, 20 Mar 2023 15:46:09 -0700 (PDT) X-Google-Smtp-Source: AK7set8sUsEWUDlHCC2T4GZdpSFgg45rHEEml+eq2CDUASgnEaEkhWkpE3DfeG7e1FA/k/LnFa/w X-Received: by 2002:a62:1990:0:b0:625:b37d:875 with SMTP id 138-20020a621990000000b00625b37d0875mr301990pfz.32.1679352369214; Mon, 20 Mar 2023 15:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679352369; cv=none; d=google.com; s=arc-20160816; b=LlcqiZmBoxXJpE+IP89ruUhq41Q1Ys5hzFdO8sqwdJed8gMdv+C8EzYP4hc+o8WMvM Mu72SNTkrGSUe6rk91A1fGU8ILzR0PvMhSF4uY4VJF0KyB4jIwki04N4oRgWjBZnlSEt AMp3ZzTDMJamIOr45XeRwKdgHZ066NFm0qpAxvrVHu1UJ0DcIYtxIDQkuRD+nfAUiRlI 275w2aC2B3cRSNoYZmJTiRVrTsOeaS2Mr8zey9H0u2WlHKheMYZLWKlWrnkiw8FE/y5p 0ri93t4a4nyL9NM6nBYQuc00+7xt8YNjaBycRRwnTsbx2QHMEtpnJRtaYpVMZ9Bhvlws 3V1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mPLmB3dzpBczm3qRE9s2V0X3S8uJO7/jVxWe+sb20rE=; b=bB6SdO18frMBb1BHg7Wc6YP74QdEUNpgXsS9n/oPphXn5QXd6hJsufH5y/eDD4L8ls IeDr1u/nbIAzn9qI0WkSehyk7vD8iBMXSi4TnSAieNJsTSpy0q8+V3Asug96QkjXbGsL DXOtojbIGwq4exGHwfc7V5dTfjxsyMEwCntGpFFJTAw2h0pNoue+MpPcG8n012X+Uoa7 UNBpEaAT3x10t18jPumMV21vg34O+qReYwogmHfTaUf9QEPYuDKtGyZhUDvExnzQlBCs qXDB9Av+LBK9Va27uPIiLlRpY0XIAg2UeJIzq2rZq9hlYJgXH2Xiow4KA3NJllvZoO7k 3G3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VZXByqS8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 31-20020a630d5f000000b0050bf617d84fsi10959977pgn.249.2023.03.20.15.45.56; Mon, 20 Mar 2023 15:46:09 -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=VZXByqS8; 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 S229675AbjCTWUf (ORCPT + 99 others); Mon, 20 Mar 2023 18:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjCTWUQ (ORCPT ); Mon, 20 Mar 2023 18:20:16 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CB3B1D937 for ; Mon, 20 Mar 2023 15:18:31 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso17987509pjb.3 for ; Mon, 20 Mar 2023 15:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679350710; 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=mPLmB3dzpBczm3qRE9s2V0X3S8uJO7/jVxWe+sb20rE=; b=VZXByqS8gHum2nUGLIN3iOP/iDUJ34c9r8a9Mm2c8bP2DU0bJMcb4l7vWherdXtZqv 0Cx81BbLUunRRC50uVwkKjqcMCSvjwdPd+RQS3f5uNZQyFnwIV0zlT6f+M6/wqDAK4KE ZMq7MpX3CmWy/wW+7GZX3KR9NR2L9AG2XPpLcQ+0wfTLDchs92oD9mMmkumxD4Ktdzuh qiQRxVpo0tCBPTugl+oMPgO1IqmdhmZK4WpYVQqIEvGtTAyuc8QGoi61qMxwSKJPFKvf pq6iD/fs8VR9NYw6pbSR95vfLcju1ljWtDCYvl6rfd5tSTSxTZwp4pIB0UFbRv+622U8 m4+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679350710; 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=mPLmB3dzpBczm3qRE9s2V0X3S8uJO7/jVxWe+sb20rE=; b=SFPrIsPF//kiEYZQq1GxdViuVBQghqNt8wksW9Pe7dTZsrgeEM1DdngZDahu7wb7eT rwscNuW/+NIr/abMwj2QVvn/UdQG038dLK8YR0aGG5hMayt0asHzAznMb8Pl4iR/0qDC TeOrEvx5MDZTUk2Q6L0v1svZWh9wENGbow7kbHeeMGA+JT703PGH42FlRCOx253UM78+ 4rOCRbciQT6IT60/ckoLtEusqY/Q5/3noiaByYRgyOCfuRdB0vUoRB1KZgMrWTdVydMS OWfh9tkQJ/nWeVvte1PuFMEh5so4/pO3p6Lrjb5bb5kPEcaZJYUndxXWbFGYlYHxJDl5 eUpw== X-Gm-Message-State: AO0yUKV49/s+zmWFQvdaFX+9m3mV5miPuhYG8Ma9O1an9z5oSaMlE97p jn/skHjC91kBMz70514ufp2vvA== X-Received: by 2002:a05:6a20:4f1f:b0:c2:fb92:3029 with SMTP id gi31-20020a056a204f1f00b000c2fb923029mr35523pzb.33.1679350710546; Mon, 20 Mar 2023 15:18:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 15:18:30 -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 1/5] remoteproc: stm32: Call of_node_put() on iteration error Date: Mon, 20 Mar 2023 16:18:22 -0600 Message-Id: <20230320221826.2728078-2-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760928590233574009?= X-GMAIL-MSGID: =?utf-8?q?1760928590233574009?= 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 reviewed-by: Arnaud Pouliquen --- 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; + } rproc_add_carveout(rproc, mem); index++;