summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeleswar Padhi <b-padhi@ti.com>2024-12-19 16:35:42 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-10 16:05:02 +0200
commite392148f7fa0f91715d79a391e5e9e51985b9cb0 (patch)
treef6fd6c8a96b8456d9856d13f43ad287b2f911b52
parentf802fb717dfd516268fb90de16e1c1a3890db393 (diff)
remoteproc: k3-r5: Use devm_kcalloc() helper
[ Upstream commit f2e3d0d70986b1f135963dc28462fce4e65c0fc4 ] Use a device lifecycle managed action to free memory. This helps prevent mistakes like freeing out of order in cleanup functions and forgetting to free on error paths. Signed-off-by: Beleswar Padhi <b-padhi@ti.com> Reviewed-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20241219110545.1898883-3-b-padhi@ti.com 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>
-rw-r--r--drivers/remoteproc/ti_k3_r5_remoteproc.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index a9ec65c12fb9..c730ba09b92c 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -989,7 +989,7 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
return ret;
num_rmems--;
- kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
+ kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
if (!kproc->rmem)
return -ENOMEM;
@@ -1041,7 +1041,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
unmap_rmem:
for (i--; i >= 0; i--)
iounmap(kproc->rmem[i].cpu_addr);
- kfree(kproc->rmem);
return ret;
}
@@ -1051,7 +1050,6 @@ static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc)
for (i = 0; i < kproc->num_rmems; i++)
iounmap(kproc->rmem[i].cpu_addr);
- kfree(kproc->rmem);
}
/*