[PATCH v10 07/15] scsi: scsi_devinfo: preserve full-width quirk identifiers

From: Phil Pemberton

Date: Fri Oct 09 2026 - 12:31:22 EST


strscpy_pad() reserves a byte for NUL termination, truncating quirk
identifiers that fill their fields. An eight-character vendor such as
MATSHITA loses its final character and fails to match. A sixteen-character
model loses its final character too; prefix matching then allows the
quirk to match other models with the same first fifteen characters.

Copy the full vendor and model fields. Pad shorter strings with NUL for
compatible entries and spaces for dynamic entries. Lookup uses bounded
strnlen() and memcmp(), so full-width identifiers need no terminator.
Shorter model names continue to match prefixes.

Fixes: 1b60c86dd992 ("scsi: devinfo: Replace strncpy() and manual pad")
Link: https://lore.kernel.org/linux-ide/20260611025249.D23191F00893@xxxxxxxxxxxxxxx/
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Phil Pemberton <philpem@xxxxxxxxxxxxx>
---
drivers/scsi/scsi_devinfo.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 88a911b35c94..5e37461e61e8 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -289,14 +289,9 @@ static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,

from_length = strlen(from);

- /*
- * null pad and null terminate if compatible
- * otherwise space pad
- */
- if (compatible)
- strscpy_pad(to, from, to_length);
- else
- memcpy_and_pad(to, to_length, from, from_length, ' ');
+ /* Full-width identifiers need all bytes; shorter ones are padded. */
+ memcpy_and_pad(to, to_length, from, from_length,
+ compatible ? '\0' : ' ');

if (from_length > to_length)
printk(KERN_WARNING "%s: %s string '%s' is too long\n",
--
2.43.0