Skip to content

Commit f2e3d0d

Browse files
3V3RYONEmathieupoirier
authored andcommitted
remoteproc: k3-r5: Use devm_kcalloc() helper
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 <[email protected]> Reviewed-by: Andrew Davis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 972361e commit f2e3d0d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/remoteproc/ti_k3_r5_remoteproc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
997997
return ret;
998998

999999
num_rmems--;
1000-
kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
1000+
kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
10011001
if (!kproc->rmem)
10021002
return -ENOMEM;
10031003

@@ -1049,7 +1049,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
10491049
unmap_rmem:
10501050
for (i--; i >= 0; i--)
10511051
iounmap(kproc->rmem[i].cpu_addr);
1052-
kfree(kproc->rmem);
10531052
return ret;
10541053
}
10551054

@@ -1059,7 +1058,6 @@ static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc)
10591058

10601059
for (i = 0; i < kproc->num_rmems; i++)
10611060
iounmap(kproc->rmem[i].cpu_addr);
1062-
kfree(kproc->rmem);
10631061
}
10641062

10651063
/*

0 commit comments

Comments
 (0)