+ * XXX Changed my mind: leave max prot at VM_PROT_ALL.
+ * PATCH GVR 25-03-93:
+ * Changed again: indeed set maximum protection based on
+ * object permissions.
+ */
+ /*
+ * We only need to set max_protection in case it's
+ * unequal to its default, which is VM_PROT_DEFAULT.
+ */
+ if (maxprot != VM_PROT_DEFAULT) {
+ rv = vm_map_protect(map, *addr, *addr+size, maxprot, TRUE);
+ if (rv != KERN_SUCCESS) {
+ (void) vm_deallocate(map, *addr, size);
+ goto out;
+ }
+ }
+ /*
+ * We only need to set the protection if it is unequal
+ * to the maximum (if it is equal to maxprot, and isn't
+ * the default, then it would have been set above when
+ * maximum prot was set.