Skip to content

Commit d4f75b5

Browse files
rolanddNicholas Bellinger
authored andcommitted
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 <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 9389c3c commit d4f75b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ static char *tcm_qla2xxx_get_fabric_name(void)
137137
*/
138138
static int tcm_qla2xxx_npiv_extract_wwn(const char *ns, u64 *nm)
139139
{
140-
unsigned int i, j, value;
140+
unsigned int i, j;
141141
u8 wwn[8];
142142

143143
memset(wwn, 0, sizeof(wwn));
144144

145145
/* Validate and store the new name */
146146
for (i = 0, j = 0; i < 16; i++) {
147+
int value;
148+
147149
value = hex_to_bin(*ns++);
148150
if (value >= 0)
149151
j = (j << 4) | value;

0 commit comments

Comments
 (0)