Skip to content

Commit ccadca5

Browse files
remoteproc: stm32: Call of_node_put() on iteration error
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: 13140de ("remoteproc: stm32: add an ST stm32_rproc driver") Cc: stable@vger.kernel.org Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20230320221826.2728078-2-mathieu.poirier@linaro.org Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 5172365 commit ccadca5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/remoteproc/stm32_rproc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,13 @@ static int stm32_rproc_prepare(struct rproc *rproc)
223223
while (of_phandle_iterator_next(&it) == 0) {
224224
rmem = of_reserved_mem_lookup(it.node);
225225
if (!rmem) {
226+
of_node_put(it.node);
226227
dev_err(dev, "unable to acquire memory-region\n");
227228
return -EINVAL;
228229
}
229230

230231
if (stm32_rproc_pa_to_da(rproc, rmem->base, &da) < 0) {
232+
of_node_put(it.node);
231233
dev_err(dev, "memory region not valid %pa\n",
232234
&rmem->base);
233235
return -EINVAL;
@@ -254,8 +256,10 @@ static int stm32_rproc_prepare(struct rproc *rproc)
254256
it.node->name);
255257
}
256258

257-
if (!mem)
259+
if (!mem) {
260+
of_node_put(it.node);
258261
return -ENOMEM;
262+
}
259263

260264
rproc_add_carveout(rproc, mem);
261265
index++;

0 commit comments

Comments
 (0)