]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc()
authorBean Huo <beanhuo@micron.com>
Fri, 7 Nov 2025 23:05:17 +0000 (00:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:55 +0000 (14:02 +0100)
commitcd2898f0fd8efa34874affdd87f99b06e9bff03e
tree3a3ed32ddfb7352448a5b344a23c76c85ac5a2d9
parentee8b0b284ccff4035f74367db721922f7a053ad8
scsi: ufs: core: fix incorrect buffer duplication in ufshcd_read_string_desc()

[ Upstream commit d794b499f948801f54d67ddbc34a6eac5a6d150a ]

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@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>
drivers/ufs/core/ufshcd.c