From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC4C517730 for ; Mon, 15 May 2023 18:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E0D7C433D2; Mon, 15 May 2023 18:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684173915; bh=5wjzqH+2Y5iIq22pkivcC90P6ll8N35Z0etTh4AKX5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XefEdEKs6P79clP4zLAH5IISoXAbbjmXBZK05/W2jb8ZT8VSc5KbiiQidHUhljANS Iz7P6HUZIfxCfYNCAxspvNE5LnI797PFg2u7KRUHX6+1D/7bq8rd4uW9BL4PPtos/8 KSwdf28eHUjPT9gV9b5mZkl0siZ2XPx5SV108Q1c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mathieu Poirier , Arnaud Pouliquen Subject: [PATCH 5.4 248/282] remoteproc: stm32: Call of_node_put() on iteration error Date: Mon, 15 May 2023 18:30:26 +0200 Message-Id: <20230515161729.695693333@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515161722.146344674@linuxfoundation.org> References: <20230515161722.146344674@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Mathieu Poirier commit ccadca5baf5124a880f2bb50ed1ec265415f025b upstream. 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 Link: https://lore.kernel.org/r/20230320221826.2728078-2-mathieu.poirier@linaro.org Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/remoteproc/stm32_rproc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -211,11 +211,13 @@ static int stm32_rproc_parse_fw(struct r 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; @@ -242,8 +244,10 @@ static int stm32_rproc_parse_fw(struct r it.node->name); } - if (!mem) + if (!mem) { + of_node_put(it.node); return -ENOMEM; + } rproc_add_carveout(rproc, mem); index++;