Skip to content

Commit 90138ed

Browse files
beanhuogregkh
authored andcommitted
scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc()
[ Upstream commit d794b49 ] 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: 5f57704 ("scsi: ufs: Use kmemdup in ufshcd_read_string_desc()") Reviewed-by: Avri Altman <avri.altman@sandisk.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Bean Huo <beanhuo@micron.com> Link: https://patch.msgid.link/20251107230518.4060231-3-beanhuo@iokpp.de Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 98ae402 commit 90138ed

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
37993799
str[ret++] = '\0';
38003800

38013801
} else {
3802-
str = kmemdup(uc_str, uc_str->len, GFP_KERNEL);
3802+
str = kmemdup(uc_str->uc, uc_str->len, GFP_KERNEL);
38033803
if (!str) {
38043804
ret = -ENOMEM;
38053805
goto out;

0 commit comments

Comments
 (0)