Commit d794b499 authored by Bean Huo's avatar Bean Huo Committed by Martin K. Petersen
Browse files

scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc()



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: 5f57704d ("scsi: ufs: Use kmemdup in ufshcd_read_string_desc()")
Reviewed-by: default avatarAvri Altman <avri.altman@sandisk.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
Link: https://patch.msgid.link/20251107230518.4060231-3-beanhuo@iokpp.de


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 0d9a7085
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3835,7 +3835,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;