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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f802fb717d
commit
e392148f7f
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user