nvme: telemetry: report the correct error if the ioctl() fails.
It's wrong to assume that if the ioctl() returns a non-zero number
then the errno variable is set.
The ioctl() might return an NVMe Status error to inform the caller
that the requested log page is not supported, in that case errno is left
untouched.
The original code didn't handle this case and returned "-errno" even when
the latter was zero. The caller interpreted this as a successful operation
and this might lead to improperly dereferencing the log page pointer.
$ nvme telemetry-log /dev/nvme0 --output-file=telemetry_log.bin
ERROR: get_telemetry_log: : write failed with error : Bad address
Fix this bug by returning the NVMe status if errno is zero:
$ nvme telemetry-log /dev/nvme0 --output-file=telemetry_log.bin
NVMe status: Invalid Log Page: The log page indicated is invalid(0x109)
Failed to acquire telemetry log 265!