Message ID | 20210517084913.403-1-xieyongji@bytedance.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] drm/virtio: Fixes a potential NULL pointer dereference on probe failure | expand |
On Mon, May 17, 2021 at 04:49:11PM +0800, Xie Yongji wrote: > The dev->dev_private might not be allocated if virtio_gpu_pci_quirk() > or virtio_gpu_init() failed. In this case, we should avoid the cleanup > in virtio_gpu_release(). Pushed all three to drm-misc-next. thanks, Gerd
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index b375394193be..aa532ad31a23 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -264,6 +264,9 @@ void virtio_gpu_release(struct drm_device *dev) { struct virtio_gpu_device *vgdev = dev->dev_private; + if (!vgdev) + return; + virtio_gpu_modeset_fini(vgdev); virtio_gpu_free_vbufs(vgdev); virtio_gpu_cleanup_cap_cache(vgdev);
The dev->dev_private might not be allocated if virtio_gpu_pci_quirk() or virtio_gpu_init() failed. In this case, we should avoid the cleanup in virtio_gpu_release(). Signed-off-by: Xie Yongji <xieyongji@bytedance.com> --- drivers/gpu/drm/virtio/virtgpu_kms.c | 3 +++ 1 file changed, 3 insertions(+)