mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
remoteproc: qcom: Fix leak when custom dump_segments addition fails
Free allocated minidump_region 'name' in qcom_add_minidump_segments()
when failing before adding the region to 'dump_segments'. Otherwise,
the 'name' is not tracked and is never freed by qcom_minidump_cleanup().
Return error when adding to 'dump_segments' fails.
Cc: stable@vger.kernel.org # v5.11
Fixes: 8ed8485c4f ("remoteproc: qcom: Add capability to collect minidumps")
Reviewed-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
Signed-off-by: Wasim Nazir <wasim.nazir@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260318-rproc-memleak-v2-1-ade70ab858f2@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
This commit is contained in:
committed by
Bjorn Andersson
parent
6ad61d0acd
commit
ecf9fc18e6
@@ -109,6 +109,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
|
||||
struct minidump_region __iomem *ptr;
|
||||
struct minidump_region region;
|
||||
int seg_cnt, i;
|
||||
int ret = 0;
|
||||
dma_addr_t da;
|
||||
size_t size;
|
||||
char *name;
|
||||
@@ -129,17 +130,22 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
|
||||
if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
|
||||
name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
|
||||
if (!name) {
|
||||
iounmap(ptr);
|
||||
return -ENOMEM;
|
||||
ret = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
da = le64_to_cpu(region.address);
|
||||
size = le64_to_cpu(region.size);
|
||||
rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
|
||||
ret = rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t,
|
||||
name);
|
||||
if (ret) {
|
||||
kfree(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iounmap(ptr);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
|
||||
|
||||
Reference in New Issue
Block a user