Actually return the device_mem value in Device::malloc, also update CUDADevice to use mem_flags instead of permission