summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2017-11-20 19:12:43 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2018-01-12 18:07:09 -0500
commit094bb5d766cfcdae47e332c6d6713c7029241be1 (patch)
tree45cb641e8bf2701941c24499febbfad2fdb42100 /drivers/target
parent30a7acd573899fd8b8ac39236eff6468b195ac7d (diff)
target-core: don't use "const char*" for a buffer that is written to
iscsi_parse_pr_out_transport_id launders the const away via a call to strstr(), and then modifies the buffer (writing a nul byte) through the return value. It's cleaner to be honest and simply declare the parameter as "char*", fixing up the call chain, and allowing us to drop the cast in the return statement. Amusingly, the two current callers found it necessary to cast a non-const pointer to a const. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_fabric_lib.c6
-rw-r--r--drivers/target/target_core_internal.h2
-rw-r--r--drivers/target/target_core_pr.c4
3 files changed, 6 insertions, 6 deletions
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index 508da345b73f..71a80257a052 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -273,7 +273,7 @@ static int iscsi_get_pr_transport_id_len(
273 273
274static char *iscsi_parse_pr_out_transport_id( 274static char *iscsi_parse_pr_out_transport_id(
275 struct se_portal_group *se_tpg, 275 struct se_portal_group *se_tpg,
276 const char *buf, 276 char *buf,
277 u32 *out_tid_len, 277 u32 *out_tid_len,
278 char **port_nexus_ptr) 278 char **port_nexus_ptr)
279{ 279{
@@ -356,7 +356,7 @@ static char *iscsi_parse_pr_out_transport_id(
356 } 356 }
357 } 357 }
358 358
359 return (char *)&buf[4]; 359 return &buf[4];
360} 360}
361 361
362int target_get_pr_transport_id_len(struct se_node_acl *nacl, 362int target_get_pr_transport_id_len(struct se_node_acl *nacl,
@@ -405,7 +405,7 @@ int target_get_pr_transport_id(struct se_node_acl *nacl,
405} 405}
406 406
407const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg, 407const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg,
408 const char *buf, u32 *out_tid_len, char **port_nexus_ptr) 408 char *buf, u32 *out_tid_len, char **port_nexus_ptr)
409{ 409{
410 u32 offset; 410 u32 offset;
411 411
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 9384d19a7326..6d53d9fcb883 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -102,7 +102,7 @@ int target_get_pr_transport_id(struct se_node_acl *nacl,
102 struct t10_pr_registration *pr_reg, int *format_code, 102 struct t10_pr_registration *pr_reg, int *format_code,
103 unsigned char *buf); 103 unsigned char *buf);
104const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg, 104const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg,
105 const char *buf, u32 *out_tid_len, char **port_nexus_ptr); 105 char *buf, u32 *out_tid_len, char **port_nexus_ptr);
106 106
107/* target_core_hba.c */ 107/* target_core_hba.c */
108struct se_hba *core_alloc_hba(const char *, u32, u32); 108struct se_hba *core_alloc_hba(const char *, u32, u32);
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index b024613f9217..01ac306131c1 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -1601,7 +1601,7 @@ core_scsi3_decode_spec_i_port(
1601 dest_rtpi = tmp_lun->lun_rtpi; 1601 dest_rtpi = tmp_lun->lun_rtpi;
1602 1602
1603 i_str = target_parse_pr_out_transport_id(tmp_tpg, 1603 i_str = target_parse_pr_out_transport_id(tmp_tpg,
1604 (const char *)ptr, &tid_len, &iport_ptr); 1604 ptr, &tid_len, &iport_ptr);
1605 if (!i_str) 1605 if (!i_str)
1606 continue; 1606 continue;
1607 1607
@@ -3287,7 +3287,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
3287 goto out; 3287 goto out;
3288 } 3288 }
3289 initiator_str = target_parse_pr_out_transport_id(dest_se_tpg, 3289 initiator_str = target_parse_pr_out_transport_id(dest_se_tpg,
3290 (const char *)&buf[24], &tmp_tid_len, &iport_ptr); 3290 &buf[24], &tmp_tid_len, &iport_ptr);
3291 if (!initiator_str) { 3291 if (!initiator_str) {
3292 pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate" 3292 pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate"
3293 " initiator_str from Transport ID\n"); 3293 " initiator_str from Transport ID\n");