]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
remoteproc: k3: Call of_node_put(rmem_np) only once in three functions
authorMarkus Elfring <elfring@users.sourceforge.net>
Tue, 24 Sep 2024 12:28:35 +0000 (14:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2025 14:05:01 +0000 (16:05 +0200)
[ Upstream commit a36d9f96d1cf7c0308bf091e810bec06ce492c3d ]

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>
Stable-dep-of: 701177511abd ("remoteproc: k3-r5: Refactor sequential core power up/down operations")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/remoteproc/ti_k3_dsp_remoteproc.c
drivers/remoteproc/ti_k3_m4_remoteproc.c
drivers/remoteproc/ti_k3_r5_remoteproc.c

index 2ae0655ddf1d22f28dc2cdb8f822fbef15b5c33b..73be3d21679148ccb265927d85b93a616a99bc6f 100644 (file)
@@ -568,11 +568,9 @@ static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc)
                        return -EINVAL;
 
                rmem = of_reserved_mem_lookup(rmem_np);
-               if (!rmem) {
-                       of_node_put(rmem_np);
-                       return -EINVAL;
-               }
                of_node_put(rmem_np);
+               if (!rmem)
+                       return -EINVAL;
 
                kproc->rmem[i].bus_addr = rmem->base;
                /* 64-bit address regions currently not supported */
index fba6e393635e369e40b03efd8a496f6e725f8579..6cd50b16a8e82a23e762983206b99e995526c934 100644 (file)
@@ -433,11 +433,9 @@ static int k3_m4_reserved_mem_init(struct k3_m4_rproc *kproc)
                        return -EINVAL;
 
                rmem = of_reserved_mem_lookup(rmem_np);
-               if (!rmem) {
-                       of_node_put(rmem_np);
-                       return -EINVAL;
-               }
                of_node_put(rmem_np);
+               if (!rmem)
+                       return -EINVAL;
 
                kproc->rmem[i].bus_addr = rmem->base;
                /* 64-bit address regions currently not supported */
index 4894461aa65f3b6d882673d67e3a2b478cbbc63e..6cbe74486ebd48afdb96e18296ae5d2df7b184aa 100644 (file)
@@ -993,12 +993,11 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
                }
 
                rmem = of_reserved_mem_lookup(rmem_np);
+               of_node_put(rmem_np);
                if (!rmem) {
-                       of_node_put(rmem_np);
                        ret = -EINVAL;
                        goto unmap_rmem;
                }
-               of_node_put(rmem_np);
 
                kproc->rmem[i].bus_addr = rmem->base;
                /*