FAILED: patch "[PATCH] remoteproc: qcom: Fix leak when custom dump_segments addition" failed to apply to 6.1-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x ecf9fc18e62c58eae1ceb65dab2bccb8a724de2d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072052-revenge-discount-456e@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ecf9fc18e62c58eae1ceb65dab2bccb8a724de2d Mon Sep 17 00:00:00 2001
From: Wasim Nazir <[email protected]>
Date: Wed, 18 Mar 2026 17:19:16 +0530
Subject: [PATCH] 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.
drivers/remoteproc/qcom_common.c +10 -4
@@ -109,6 +109,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystruct 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_subsyif (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,
Sasha Levin
maintainerPATCH 1/4 remoteproc: qcom: replace kstrdup with kstrndup
From: Mukesh Ojha <[email protected]>
[ Upstream commit 9d5b9ad97f83b2390a6006eeb5ae5e48ec4298ce ]
Since, there is no guarantee that region.name will be 0-terminated from the firmware side, replace kstrdup with kstrndup.
Stable-dep-of: ecf9fc18e62c ("remoteproc: qcom: Fix leak when custom dump_segments addition fails")
--- drivers/remoteproc/qcom_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/qcom_common.c +1 -1
@@ -124,7 +124,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsyfor (i =0 ; i < seg_cnt; i++) {memcpy_fromio (®ion, ptr + i,sizeof (region));if (region.valid ==MD_REGION_VALID ) { - name =kstrdup (region.name,GFP_KERNEL ); + name =kstrndup (region.name,MAX_REGION_NAME_LENGTH -1 ,GFP_KERNEL );if (!name) {iounmap (ptr);return -ENOMEM ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 remoteproc: qcom: fix sparse warnings
From: Mukesh Ojha <[email protected]>
[ Upstream commit 2554dd0ac362738f588ba073d8333eb9b14f9587 ]
This patch try to address below sparse warnings.
drivers/remoteproc/qcom_common.c:126:27: warning: restricted __le32 degrades to integer drivers/remoteproc/qcom_common.c:133:32: warning: cast to restricted __le32 drivers/remoteproc/qcom_common.c:133:32: warning: cast from restricted __le64
Stable-dep-of: ecf9fc18e62c ("remoteproc: qcom: Fix leak when custom dump_segments addition fails")
--- drivers/remoteproc/qcom_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/qcom_common.c +2 -2
@@ -123,14 +123,14 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsyfor (i =0 ; i < seg_cnt; i++) {memcpy_fromio (®ion, ptr + i,sizeof (region)); -if (region.valid ==MD_REGION_VALID ) { +if (le32_to_cpu (region.valid) ==MD_REGION_VALID ) { name =kstrndup (region.name,MAX_REGION_NAME_LENGTH -1 ,GFP_KERNEL );if (!name) {iounmap (ptr);return -ENOMEM ; } da =le64_to_cpu (region.address); - size =le32_to_cpu (region.size); + size =le64_to_cpu (region.size);rproc_coredump_add_custom_segment (rproc, da, size,NULL , name); } }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 remoteproc: qcom: pas: Adjust the phys addr wrt the mem region
In reply to Sasha LevinFrom: Yogesh Lal <[email protected]>
[ Upstream commit a376c10d45a8e6ee5ea55791193f90625b35e156 ]
The minidump table in the toc contains physical addresses that may lie before the physical address of the first elf segment in relocatable images. This change adds a custom dump function for minidumps which calculates the offset into the carveout region using the start of the physical address instead of the start of the first elf segment.
Stable-dep-of: ecf9fc18e62c ("remoteproc: qcom: Fix leak when custom dump_segments addition fails")
--- drivers/remoteproc/qcom_common.c | 13 +++++++++---- drivers/remoteproc/qcom_common.h | 5 ++++- drivers/remoteproc/qcom_q6v5_pas.c | 20 +++++++++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-)
drivers/remoteproc/qcom_common.c +9 -4
@@ -101,7 +101,9 @@ static void qcom_minidump_cleanup(struct rproc *rproc) } } -static int qcom_add_minidump_segments (struct rproc *rproc,struct minidump_subsystem *subsystem) +static int qcom_add_minidump_segments (struct rproc *rproc,struct minidump_subsystem *subsystem, +void (*rproc_dumpfn_t)(struct rproc *rproc,struct rproc_dump_segment *segment, +void *dest,size_t offset,size_t size)) {struct minidump_region __iomem *ptr;struct minidump_region region;
@@ -131,7 +133,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy } da =le64_to_cpu (region.address); size =le64_to_cpu (region.size); -rproc_coredump_add_custom_segment (rproc, da, size,NULL , name); +rproc_coredump_add_custom_segment (rproc, da, size, rproc_dumpfn_t, name); } }
@@ -139,7 +141,10 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsyreturn 0 ; } -void qcom_minidump (struct rproc *rproc,unsigned int minidump_id) +void qcom_minidump (struct rproc *rproc,unsigned int minidump_id, +void (*rproc_dumpfn_t)(struct rproc *rproc, +struct rproc_dump_segment *segment,void *dest,size_t offset, +size_t size)) {int ret;struct minidump_subsystem *subsystem;
@@ -169,7 +174,7 @@ void qcom_minidump(struct rproc *rproc, unsigned int minidump_id)return ; } - ret =qcom_add_minidump_segments (rproc, subsystem); + ret =qcom_add_minidump_segments (rproc, subsystem, rproc_dumpfn_t);if (ret) {dev_err (&rproc->dev,"Failed with error: %d while adding minidump entries\n" , ret); goto clean_minidump;
drivers/remoteproc/qcom_common.h +4 -1
@@ -33,7 +33,10 @@ struct qcom_rproc_ssr {struct qcom_ssr_subsystem *info; }; -void qcom_minidump (struct rproc *rproc,unsigned int minidump_id); +void qcom_minidump (struct rproc *rproc,unsigned int minidump_id, +void (*rproc_dumpfn_t)(struct rproc *rproc, +struct rproc_dump_segment *segment,void *dest,size_t offset, +size_t size));void qcom_add_glink_subdev (struct rproc *rproc,struct qcom_rproc_glink *glink,const char *ssr_name);
drivers/remoteproc/qcom_q6v5_pas.c +19 -1
@@ -86,6 +86,24 @@ struct qcom_adsp {struct qcom_scm_pas_metadata pas_metadata; }; +void adsp_segment_dump (struct rproc *rproc,struct rproc_dump_segment *segment, +void *dest,size_t offset,size_t size) +{ +struct qcom_adsp *adsp = rproc->priv; +int total_offset; + + total_offset = segment->da + segment->offset + offset - adsp->mem_phys; +if (total_offset <0 || total_offset + size > adsp->mem_size) { +dev_err (adsp->dev, +"invalid copy request for segment %pad with offset %zu and size %zu)\n" , + &segment->da, offset, size); +memset (dest,0xff , size); +return ; + } + +memcpy_fromio (dest, adsp->mem_region + total_offset, size); +} +static void adsp_minidump (struct rproc *rproc) {struct qcom_adsp *adsp = rproc->priv;
@@ -93,7 +111,7 @@ static void adsp_minidump(struct rproc *rproc)if (rproc->dump_conf ==RPROC_COREDUMP_DISABLED )return ; -qcom_minidump (rproc, adsp->minidump_id); +qcom_minidump (rproc, adsp->minidump_id, adsp_segment_dump); } static int adsp_pds_enable(struct qcom_adsp *adsp, struct device **pds,
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 remoteproc: qcom: Fix leak when custom dump_segments addition fails
In reply to Sasha LevinFrom: Wasim Nazir <[email protected]>
[ Upstream commit ecf9fc18e62c58eae1ceb65dab2bccb8a724de2d ]
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.
--- drivers/remoteproc/qcom_common.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/remoteproc/qcom_common.c +10 -4
@@ -108,6 +108,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystruct minidump_region __iomem *ptr;struct minidump_region region;int seg_cnt, i; +int ret =0 ;dma_addr_t da;size_t size;char *name;
@@ -128,17 +129,22 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsyif (le32_to_cpu (region.valid) ==MD_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,
Signature · 1 line
2.53.0