Skip to content

Commit 8a74918

Browse files
remoteproc: st: 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: 3df52ed ("remoteproc: st: add reserved memory support") 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-3-mathieu.poirier@linaro.org Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent ccadca5 commit 8a74918

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/remoteproc/st_remoteproc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static int st_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
129129
while (of_phandle_iterator_next(&it) == 0) {
130130
rmem = of_reserved_mem_lookup(it.node);
131131
if (!rmem) {
132+
of_node_put(it.node);
132133
dev_err(dev, "unable to acquire memory-region\n");
133134
return -EINVAL;
134135
}
@@ -150,8 +151,10 @@ static int st_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
150151
it.node->name);
151152
}
152153

153-
if (!mem)
154+
if (!mem) {
155+
of_node_put(it.node);
154156
return -ENOMEM;
157+
}
155158

156159
rproc_add_carveout(rproc, mem);
157160
index++;

0 commit comments

Comments
 (0)