The if to allocate host memory was inverted.