Skip to content

Commit

Permalink
tcm_qla2xxx: Handle malformed wwn strings properly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roland Dreier authored and Nicholas Bellinger committed Jun 13, 2012
1 parent 9389c3c commit d4f75b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/qla2xxx/tcm_qla2xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ static char *tcm_qla2xxx_get_fabric_name(void)
*/
static int tcm_qla2xxx_npiv_extract_wwn(const char *ns, u64 *nm)
{
unsigned int i, j, value;
unsigned int i, j;
u8 wwn[8];

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

/* Validate and store the new name */
for (i = 0, j = 0; i < 16; i++) {
int value;

value = hex_to_bin(*ns++);
if (value >= 0)
j = (j << 4) | value;
Expand Down

0 comments on commit d4f75b5

Please sign in to comment.