Skip to content

Commit a36d9f9

Browse files
elfringmathieupoirier
authored andcommitted
remoteproc: k3: Call of_node_put(rmem_np) only once in three functions
An of_node_put(rmem_np) call was immediately used after a pointer check for a of_reserved_mem_lookup() call in three function implementations. Thus call such a function only once instead directly before the checks. This issue was transformed by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Link: https://lore.kernel.org/r/c46b06f9-72b1-420b-9dce-a392b982140e@web.de Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
1 parent 9852d85 commit a36d9f9

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

drivers/remoteproc/ti_k3_dsp_remoteproc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,9 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc)
576576
return -EINVAL;
577577

578578
rmem = of_reserved_mem_lookup(rmem_np);
579-
if (!rmem) {
580-
of_node_put(rmem_np);
581-
return -EINVAL;
582-
}
583579
of_node_put(rmem_np);
580+
if (!rmem)
581+
return -EINVAL;
584582

585583
kproc->rmem[i].bus_addr = rmem->base;
586584
/* 64-bit address regions currently not supported */

drivers/remoteproc/ti_k3_m4_remoteproc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,9 @@ static int k3_m4_reserved_mem_init(struct k3_m4_rproc *kproc)
433433
return -EINVAL;
434434

435435
rmem = of_reserved_mem_lookup(rmem_np);
436-
if (!rmem) {
437-
of_node_put(rmem_np);
438-
return -EINVAL;
439-
}
440436
of_node_put(rmem_np);
437+
if (!rmem)
438+
return -EINVAL;
441439

442440
kproc->rmem[i].bus_addr = rmem->base;
443441
/* 64-bit address regions currently not supported */

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,12 +1001,11 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
10011001
}
10021002

10031003
rmem = of_reserved_mem_lookup(rmem_np);
1004+
of_node_put(rmem_np);
10041005
if (!rmem) {
1005-
of_node_put(rmem_np);
10061006
ret = -EINVAL;
10071007
goto unmap_rmem;
10081008
}
1009-
of_node_put(rmem_np);
10101009

10111010
kproc->rmem[i].bus_addr = rmem->base;
10121011
/*

0 commit comments

Comments
 (0)