[PATCH for 4.4 and 4.9] dm ioctl: fix out of bounds array access when no devices