diff options
author | Roland Dreier <roland@purestorage.com> | 2012-06-11 21:31:31 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-06-12 23:15:49 -0400 |
commit | d4f75b567bb63b51e5ecd42af1e82d5aed5100dd (patch) | |
tree | 258490017b2aa269022cac58ff0c80ab329a2e3a | |
parent | 9389c3c943da7e5f903eebf79d596601537afe01 (diff) |
tcm_qla2xxx: Handle malformed wwn strings properly
If we make a variable an unsigned int and then expect it to be < 0 on
a bad character, we're going to have a bad time. Fix the tcm_qla2xxx
code to actually notice if hex_to_bin() returns a negative variable.
This was detected by the compiler warning:
scsi/qla2xxx/tcm_qla2xxx.c: In function ‘tcm_qla2xxx_npiv_extract_wwn’:
scsi/qla2xxx/tcm_qla2xxx.c:148:3: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/scsi/qla2xxx/tcm_qla2xxx.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 2f12c0921334..6e64314dbbb3 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
@@ -137,13 +137,15 @@ static char *tcm_qla2xxx_get_fabric_name(void) | |||
137 | */ | 137 | */ |
138 | static int tcm_qla2xxx_npiv_extract_wwn(const char *ns, u64 *nm) | 138 | static int tcm_qla2xxx_npiv_extract_wwn(const char *ns, u64 *nm) |
139 | { | 139 | { |
140 | unsigned int i, j, value; | 140 | unsigned int i, j; |
141 | u8 wwn[8]; | 141 | u8 wwn[8]; |
142 | 142 | ||
143 | memset(wwn, 0, sizeof(wwn)); | 143 | memset(wwn, 0, sizeof(wwn)); |
144 | 144 | ||
145 | /* Validate and store the new name */ | 145 | /* Validate and store the new name */ |
146 | for (i = 0, j = 0; i < 16; i++) { | 146 | for (i = 0, j = 0; i < 16; i++) { |
147 | int value; | ||
148 | |||
147 | value = hex_to_bin(*ns++); | 149 | value = hex_to_bin(*ns++); |
148 | if (value >= 0) | 150 | if (value >= 0) |
149 | j = (j << 4) | value; | 151 | j = (j << 4) | value; |