diff options
author | Hannes Reinecke <hare@suse.de> | 2013-12-17 03:18:47 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-12-17 14:05:33 -0500 |
commit | 03ba84ca95a84dba9b42492edd2632dc3c7eb359 (patch) | |
tree | a19747e4c25e7eb33b33eb077903f38897b66e69 /drivers/target | |
parent | 9c6e164c8c28c1f9e24441674f8b8d81551c906b (diff) |
target_core: simplify scsi_name_len calculation
scsi_name_len in spc_emulate_evpd_83 is calculated twice, with
the results of the first calculation discarded. So remove it.
And check for the maximum allowed length, too.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_spc.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 021c3f4a4f00..603c41105aa7 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -365,16 +365,6 @@ check_lu_gp: | |||
365 | * section 7.5.1 Table 362 | 365 | * section 7.5.1 Table 362 |
366 | */ | 366 | */ |
367 | check_scsi_name: | 367 | check_scsi_name: |
368 | scsi_name_len = strlen(tpg->se_tpg_tfo->tpg_get_wwn(tpg)); | ||
369 | /* UTF-8 ",t,0x<16-bit TPGT>" + NULL Terminator */ | ||
370 | scsi_name_len += 10; | ||
371 | /* Check for 4-byte padding */ | ||
372 | padding = ((-scsi_name_len) & 3); | ||
373 | if (padding != 0) | ||
374 | scsi_name_len += padding; | ||
375 | /* Header size + Designation descriptor */ | ||
376 | scsi_name_len += 4; | ||
377 | |||
378 | buf[off] = | 368 | buf[off] = |
379 | (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4); | 369 | (tpg->se_tpg_tfo->get_fabric_proto_ident(tpg) << 4); |
380 | buf[off++] |= 0x3; /* CODE SET == UTF-8 */ | 370 | buf[off++] |= 0x3; /* CODE SET == UTF-8 */ |
@@ -402,8 +392,11 @@ check_scsi_name: | |||
402 | * shall be no larger than 256 and shall be a multiple | 392 | * shall be no larger than 256 and shall be a multiple |
403 | * of four. | 393 | * of four. |
404 | */ | 394 | */ |
395 | padding = ((-scsi_name_len) & 3); | ||
405 | if (padding) | 396 | if (padding) |
406 | scsi_name_len += padding; | 397 | scsi_name_len += padding; |
398 | if (scsi_name_len > 256) | ||
399 | scsi_name_len = 256; | ||
407 | 400 | ||
408 | buf[off-1] = scsi_name_len; | 401 | buf[off-1] = scsi_name_len; |
409 | off += scsi_name_len; | 402 | off += scsi_name_len; |