[drm] Fix off-by-one error when accessing driver-specific ioctl handlers array

PR:		231513
Submitted by:	Young_X <YangX92@hotmail.com>
Approved by:	imp
MFC after:	1 week
This commit is contained in:
gonzo 2019-01-15 21:06:58 +00:00
parent 37fd65a0e1
commit 29a92ea6da

View File

@ -745,7 +745,7 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
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) {
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;