The function pmap_is_valid_memattr(pmap, mode) checks whether the given variable mode is between the two constant values VM_MEMATTR_DEVICE and VM_MEMATTR_WRITE_THROUGH. After the code for this function was written, the value of VM_MEMATTR_DEVICE changed from 0 to 4. Since VM_MEMATTR_WRITE_THROUGH is still 3, the condition is always false.
This patch changes the condition to check whether mode is equal to any of the VM_MEMATTR* constants.