test-tool: SEGV when dereferencing a NULL pointer ascq array
ascq is NULL if there are no ascqs provided for this failure mode. Do not try to dereference the 0-th element in this array before checking that the array has at least one element. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -169,7 +169,8 @@ static int check_result(const char *opcode, struct scsi_device *sdev,
|
|||||||
"have failed with %s(0x%02x)/%s(0x%04x)",
|
"have failed with %s(0x%02x)/%s(0x%04x)",
|
||||||
opcode,
|
opcode,
|
||||||
scsi_sense_key_str(key), key,
|
scsi_sense_key_str(key), key,
|
||||||
scsi_sense_ascq_str(ascq[0]), ascq[0]);
|
num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
|
||||||
|
num_ascq ? ascq[0] : 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (status == SCSI_STATUS_RESERVATION_CONFLICT
|
if (status == SCSI_STATUS_RESERVATION_CONFLICT
|
||||||
@@ -199,7 +200,8 @@ static int check_result(const char *opcode, struct scsi_device *sdev,
|
|||||||
"but failed with Sense:%s\n",
|
"but failed with Sense:%s\n",
|
||||||
opcode,
|
opcode,
|
||||||
scsi_sense_key_str(key), key,
|
scsi_sense_key_str(key), key,
|
||||||
scsi_sense_ascq_str(ascq[0]), ascq[0],
|
num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
|
||||||
|
num_ascq ? ascq[0] : 0,
|
||||||
sdev->error_str);
|
sdev->error_str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user