Skip to content

Commit

Permalink
drm: remove minor-id during unplug
Browse files Browse the repository at this point in the history
Don't delay minor removal to drm_put_minor(). Otherwise, user-space can
still open the minor and cause the kernel to oops. Instead, remove the
minor during unplug so any new open() will fail to access this minor.

Note that open() and drm_unplug_minor() are both protected by the global
DRM mutex so we're fine.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
David Herrmann authored and Dave Airlie committed Nov 6, 2013
1 parent 865fb47 commit f67e946
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/gpu/drm/drm_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ static void drm_unplug_minor(struct drm_minor *minor)
#endif

drm_sysfs_device_remove(minor);
idr_remove(&drm_minors_idr, minor->index);
}

/**
Expand All @@ -365,9 +366,6 @@ static void drm_put_minor(struct drm_minor *minor)
DRM_DEBUG("release secondary minor %d\n", minor->index);

drm_unplug_minor(minor);

idr_remove(&drm_minors_idr, minor->index);

kfree(minor);
}

Expand Down

0 comments on commit f67e946

Please sign in to comment.