Don't rely on the fact that the number of 32-bit compatibility ioctls is less than number of native ioctls. Index: sys/dev/drm2/drm_drv.c =================================================================== --- sys/dev/drm2/drm_drv.c (revision 275209) +++ sys/dev/drm2/drm_drv.c (working copy) @@ -905,11 +905,6 @@ if (ioctl->func == NULL && nr >= DRM_COMMAND_BASE) { /* The array entries begin at DRM_COMMAND_BASE ioctl nr */ nr -= DRM_COMMAND_BASE; - if (nr >= dev->driver->max_ioctl) { - DRM_DEBUG("Bad driver ioctl number, 0x%x (of 0x%x)\n", - nr, dev->driver->max_ioctl); - return EINVAL; - } #ifdef COMPAT_FREEBSD32 if (SV_CURPROC_FLAG(SV_ILP32) && nr < *dev->driver->compat_ioctls_nr && @@ -917,7 +912,13 @@ ioctl = &dev->driver->compat_ioctls[nr]; else #endif + if (nr < dev->driver->max_ioctl) ioctl = &dev->driver->ioctls[nr]; + else { + DRM_DEBUG("Bad driver ioctl number, 0x%x (of 0x%x)\n", + nr, dev->driver->max_ioctl); + return EINVAL; + } is_driver_ioctl = 1; } func = ioctl->func;