diff options
author | Ming Lin <mlin@kernel.org> | 2015-03-30 02:11:30 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-04-08 02:27:58 -0400 |
commit | 2e1cd90d718a5fc721e0caa0dc9f037d9b1f46b8 (patch) | |
tree | db299afd5e70126a52bba991a79bd2daffdf9957 /drivers/target | |
parent | 9e35eff449fc7c7106ea0fd64457afacf68f3bb3 (diff) |
tcm_loop: fixup tpgt string to integer conversion
Currently, for example, mkdir "tpgt_xyz" doesn't return error.
mkdir /sys/kernel/config/target/loopback/naa.60014055f195952b/tpgt_xyz
Replace obsoleted simple_strtoul with kstrtoul and check the conversion.
Signed-off-by: Ming Lin <mlin@kernel.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 797c7315f520..2114c1d2c9de 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -1216,21 +1216,19 @@ static struct se_portal_group *tcm_loop_make_naa_tpg( | |||
1216 | struct tcm_loop_hba *tl_hba = container_of(wwn, | 1216 | struct tcm_loop_hba *tl_hba = container_of(wwn, |
1217 | struct tcm_loop_hba, tl_hba_wwn); | 1217 | struct tcm_loop_hba, tl_hba_wwn); |
1218 | struct tcm_loop_tpg *tl_tpg; | 1218 | struct tcm_loop_tpg *tl_tpg; |
1219 | char *tpgt_str, *end_ptr; | ||
1220 | int ret; | 1219 | int ret; |
1221 | unsigned short int tpgt; | 1220 | unsigned long tpgt; |
1222 | 1221 | ||
1223 | tpgt_str = strstr(name, "tpgt_"); | 1222 | if (strstr(name, "tpgt_") != name) { |
1224 | if (!tpgt_str) { | ||
1225 | pr_err("Unable to locate \"tpgt_#\" directory" | 1223 | pr_err("Unable to locate \"tpgt_#\" directory" |
1226 | " group\n"); | 1224 | " group\n"); |
1227 | return ERR_PTR(-EINVAL); | 1225 | return ERR_PTR(-EINVAL); |
1228 | } | 1226 | } |
1229 | tpgt_str += 5; /* Skip ahead of "tpgt_" */ | 1227 | if (kstrtoul(name+5, 10, &tpgt)) |
1230 | tpgt = (unsigned short int) simple_strtoul(tpgt_str, &end_ptr, 0); | 1228 | return ERR_PTR(-EINVAL); |
1231 | 1229 | ||
1232 | if (tpgt >= TL_TPGS_PER_HBA) { | 1230 | if (tpgt >= TL_TPGS_PER_HBA) { |
1233 | pr_err("Passed tpgt: %hu exceeds TL_TPGS_PER_HBA:" | 1231 | pr_err("Passed tpgt: %lu exceeds TL_TPGS_PER_HBA:" |
1234 | " %u\n", tpgt, TL_TPGS_PER_HBA); | 1232 | " %u\n", tpgt, TL_TPGS_PER_HBA); |
1235 | return ERR_PTR(-EINVAL); | 1233 | return ERR_PTR(-EINVAL); |
1236 | } | 1234 | } |
@@ -1247,7 +1245,7 @@ static struct se_portal_group *tcm_loop_make_naa_tpg( | |||
1247 | return ERR_PTR(-ENOMEM); | 1245 | return ERR_PTR(-ENOMEM); |
1248 | 1246 | ||
1249 | pr_debug("TCM_Loop_ConfigFS: Allocated Emulated %s" | 1247 | pr_debug("TCM_Loop_ConfigFS: Allocated Emulated %s" |
1250 | " Target Port %s,t,0x%04x\n", tcm_loop_dump_proto_id(tl_hba), | 1248 | " Target Port %s,t,0x%04lx\n", tcm_loop_dump_proto_id(tl_hba), |
1251 | config_item_name(&wwn->wwn_group.cg_item), tpgt); | 1249 | config_item_name(&wwn->wwn_group.cg_item), tpgt); |
1252 | 1250 | ||
1253 | return &tl_tpg->tl_se_tpg; | 1251 | return &tl_tpg->tl_se_tpg; |