Skip to contentSkip to conversation

nvmet: fix space padding in serial number

PATCH New Daniel Verkamp 3 participants 3 messages Apr 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: fix space padding in serial number

Commit 42de82a8b544 previously attempted to fix this, and it did correctly pad the MN and FR fields with spaces, but the SN field still contains 0 bytes. The current code fills out the first 16 bytes with hex2bin, leaving the last 4 bytes zeroed. Rather than adding a lot of error-prone math to avoid overwriting SN twice, just set the whole thing to spaces up front (it's only 20 bytes).

Fixes 42de82a8b544 ("nvmet: don't report 0-bytes in serial number")
Signed-off-by Daniel Verkamp <daniel.verkamp at intel.com>
---
 drivers/nvme/target/admin-cmd.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvme/target/admin-cmd.c +1 -0
index 90dcdc40ac71..5e0e9fcc0d4d 100644
@@ -178,6 +178,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	id->vid = 0;
 	id->ssvid = 0;
 
+	memset(id->sn, ' ', sizeof(id->sn));
 	bin2hex(id->sn, &ctrl->subsys->serial,
 		min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2));
 	memcpy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1, ' ');
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/1 nvmet: fix space padding in serial number

Quoted 10 lines · Daniel Verkamp

Commit 42de82a8b544 previously attempted to fix this, and it did correctly pad the MN and FR fields with spaces, but the SN field still
contains 0 bytes. The current code fills out the first 16 bytes with hex2bin, leaving the last 4 bytes zeroed. Rather than adding a lot of
error-prone math to avoid overwriting SN twice, just set the whole thing
to spaces up front (it's only 20 bytes).

Quoted 2 lines
Fixes 42de82a8b544 ("nvmet: don't report 0-bytes in serial number")
Signed-off-by Daniel Verkamp <daniel.verkamp at intel.com>
Reviewed-by Martin Wilck <mwilck at suse.com>
Signature · 3 lines
Dr. Martin Wilck <mwilck at suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Applied
#2 lore raw

PATCH 1/1 nvmet: fix space padding in serial number

Applied, thank you.