提交 d6dea92a 编写于 作者: N Noralf Trønnes 提交者: Greg Kroah-Hartman

drm/drv: Hold ref on parent device during drm_device lifetime

[ Upstream commit 56be6503aab2bc3a30beae408071b9be5e1bae51 ]

This makes it safe to access drm_device->dev after the parent device has
been removed/unplugged.
Signed-off-by: NNoralf Trønnes <noralf@tronnes.org>
Reviewed-by: NGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190225144232.20761-2-noralf@tronnes.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
上级 473bc1af
...@@ -499,7 +499,7 @@ int drm_dev_init(struct drm_device *dev, ...@@ -499,7 +499,7 @@ int drm_dev_init(struct drm_device *dev,
} }
kref_init(&dev->ref); kref_init(&dev->ref);
dev->dev = parent; dev->dev = get_device(parent);
dev->driver = driver; dev->driver = driver;
INIT_LIST_HEAD(&dev->filelist); INIT_LIST_HEAD(&dev->filelist);
...@@ -568,6 +568,7 @@ int drm_dev_init(struct drm_device *dev, ...@@ -568,6 +568,7 @@ int drm_dev_init(struct drm_device *dev,
drm_minor_free(dev, DRM_MINOR_RENDER); drm_minor_free(dev, DRM_MINOR_RENDER);
drm_fs_inode_free(dev->anon_inode); drm_fs_inode_free(dev->anon_inode);
err_free: err_free:
put_device(dev->dev);
mutex_destroy(&dev->master_mutex); mutex_destroy(&dev->master_mutex);
mutex_destroy(&dev->ctxlist_mutex); mutex_destroy(&dev->ctxlist_mutex);
mutex_destroy(&dev->clientlist_mutex); mutex_destroy(&dev->clientlist_mutex);
...@@ -603,6 +604,8 @@ void drm_dev_fini(struct drm_device *dev) ...@@ -603,6 +604,8 @@ void drm_dev_fini(struct drm_device *dev)
drm_minor_free(dev, DRM_MINOR_PRIMARY); drm_minor_free(dev, DRM_MINOR_PRIMARY);
drm_minor_free(dev, DRM_MINOR_RENDER); drm_minor_free(dev, DRM_MINOR_RENDER);
put_device(dev->dev);
mutex_destroy(&dev->master_mutex); mutex_destroy(&dev->master_mutex);
mutex_destroy(&dev->ctxlist_mutex); mutex_destroy(&dev->ctxlist_mutex);
mutex_destroy(&dev->clientlist_mutex); mutex_destroy(&dev->clientlist_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册