From: Mukesh Ojha Date: Tue, 14 Feb 2023 14:08:11 +0000 (+0530) Subject: remoteproc: qcom: replace kstrdup with kstrndup X-Git-Tag: v6.6.17~5415^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d5b9ad97f83b2390a6006eeb5ae5e48ec4298ce;p=platform%2Fkernel%2Flinux-rpi.git remoteproc: qcom: replace kstrdup with kstrndup Since, there is no guarantee that region.name will be 0-terminated from the firmware side, replace kstrdup with kstrndup. Suggested-by: Dmitry Baryshkov Signed-off-by: Mukesh Ojha Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/1676383691-29738-1-git-send-email-quic_mojha@quicinc.com --- diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 020349f..7810f91 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -124,7 +124,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy for (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;