[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251008201920.89575-3-beanhuo@iokpp.de>
Date: Wed, 8 Oct 2025 22:19:19 +0200
From: Bean Huo <beanhuo@...pp.de>
To: avri.altman@....com,
avri.altman@...disk.com,
bvanassche@....org,
alim.akhtar@...sung.com,
jejb@...ux.ibm.com,
martin.petersen@...cle.com,
can.guo@....qualcomm.com,
ulf.hansson@...aro.org,
beanhuo@...ron.com,
jens.wiklander@...aro.org
Cc: linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 2/3] scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc()
From: Bean Huo <beanhuo@...ron.com>
The function ufshcd_read_string_desc() was duplicating memory starting
from the beginning of struct uc_string_id, which included the length
and type fields. As a result, the allocated buffer contained unwanted
metadata in addition to the string itself.
The correct behavior is to duplicate only the Unicode character array in
the structure. Update the code so that only the actual string content is
copied into the new buffer.
Fixes: 5f57704dbcfe ("scsi: ufs: Use kmemdup in ufshcd_read_string_desc()")
Reviewed-by: Avri Altman <avri.altman@...disk.com>
Reviewed-by: Bart Van Assche <bvanassche@....org>
Signed-off-by: Bean Huo <beanhuo@...ron.com>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 773926b04149..d65169733a69 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -3821,7 +3821,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum u
str[ret++] = '\0';
} else {
- str = kmemdup(uc_str, uc_str->len, GFP_KERNEL);
+ str = kmemdup(uc_str->uc, uc_str->len, GFP_KERNEL);
if (!str) {
ret = -ENOMEM;
goto out;
--
2.34.1
Powered by blists - more mailing lists