diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-06-15 13:17:48 +0100 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-06-17 09:43:29 +0200 |
commit | 40daac6136948dc83c1dec14fe4a2444915b22df (patch) | |
tree | d1a6fd9ec859efb4ae9b241dbb5b642d9a20cbc2 /drivers/gpu/drm/drm_crtc.c | |
parent | aaf285e2e0ff490e924dbcdfd08e8274c3093354 (diff) | |
download | lwn-40daac6136948dc83c1dec14fe4a2444915b22df.tar.gz lwn-40daac6136948dc83c1dec14fe4a2444915b22df.zip |
drm: Make drm_connector_register() safe against multiple calls
Protect against drivers that may try to register the connector more
than once, or who try to unregister it multiple times.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Airlie <airlied@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1465993109-19523-4-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 23dfec41decb..ea5ec641eacc 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -984,6 +984,9 @@ int drm_connector_register(struct drm_connector *connector) { int ret; + if (connector->registered) + return 0; + ret = drm_sysfs_connector_add(connector); if (ret) return ret; @@ -1001,6 +1004,7 @@ int drm_connector_register(struct drm_connector *connector) drm_mode_object_register(connector->dev, &connector->base); + connector->registered = true; return 0; err_debugfs: @@ -1019,11 +1023,16 @@ EXPORT_SYMBOL(drm_connector_register); */ void drm_connector_unregister(struct drm_connector *connector) { + if (!connector->registered) + return; + if (connector->funcs->early_unregister) connector->funcs->early_unregister(connector); drm_sysfs_connector_remove(connector); drm_debugfs_connector_remove(connector); + + connector->registered = false; } EXPORT_SYMBOL(drm_connector_unregister); |