* [PATCH AUTOSEL 4.9 08/35] drm/virtio: Fixes a potential NULL pointer dereference on probe failure [not found] <20210706112848.2066036-1-sashal@kernel.org> @ 2021-07-06 11:28 ` Sasha Levin 2021-07-06 11:28 ` [PATCH AUTOSEL 4.9 09/35] drm/virtio: Fix double free " Sasha Levin 1 sibling, 0 replies; 2+ messages in thread From: Sasha Levin @ 2021-07-06 11:28 UTC (permalink / raw) To: linux-kernel, stable Cc: Sasha Levin, Xie Yongji, Gerd Hoffmann, dri-devel, virtualization From: Xie Yongji <xieyongji@bytedance.com> [ Upstream commit 17f46f488a5d82c5568e6e786cd760bba1c2ee09 ] 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> Link: http://patchwork.freedesktop.org/patch/msgid/20210517084913.403-1-xieyongji@bytedance.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/gpu/drm/virtio/virtgpu_kms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index ba7855da7c7f..d8b2027730d0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -258,6 +258,9 @@ int virtio_gpu_driver_unload(struct drm_device *dev) flush_work(&vgdev->config_changed_work); vgdev->vdev->config->del_vqs(vgdev->vdev); + if (!vgdev) + return; + virtio_gpu_modeset_fini(vgdev); virtio_gpu_ttm_fini(vgdev); virtio_gpu_free_vbufs(vgdev); -- 2.30.2 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH AUTOSEL 4.9 09/35] drm/virtio: Fix double free on probe failure [not found] <20210706112848.2066036-1-sashal@kernel.org> 2021-07-06 11:28 ` [PATCH AUTOSEL 4.9 08/35] drm/virtio: Fixes a potential NULL pointer dereference on probe failure Sasha Levin @ 2021-07-06 11:28 ` Sasha Levin 1 sibling, 0 replies; 2+ messages in thread From: Sasha Levin @ 2021-07-06 11:28 UTC (permalink / raw) To: linux-kernel, stable Cc: Sasha Levin, Xie Yongji, Gerd Hoffmann, dri-devel, virtualization From: Xie Yongji <xieyongji@bytedance.com> [ Upstream commit cec7f1774605a5ef47c134af62afe7c75c30b0ee ] The virtio_gpu_init() will free vgdev and vgdev->vbufs on failure. But such failure will be caught by virtio_gpu_probe() and then virtio_gpu_release() will be called to do some cleanup which will free vgdev and vgdev->vbufs again. So let's set dev->dev_private to NULL to avoid double free. Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Link: http://patchwork.freedesktop.org/patch/msgid/20210517084913.403-2-xieyongji@bytedance.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index d8b2027730d0..cde38e14232c 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -234,6 +234,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) err_vbufs: vgdev->vdev->config->del_vqs(vgdev->vdev); err_vqs: + dev->dev_private = NULL; kfree(vgdev); return ret; } -- 2.30.2 ^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-06 11:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210706112848.2066036-1-sashal@kernel.org>
2021-07-06 11:28 ` [PATCH AUTOSEL 4.9 08/35] drm/virtio: Fixes a potential NULL pointer dereference on probe failure Sasha Levin
2021-07-06 11:28 ` [PATCH AUTOSEL 4.9 09/35] drm/virtio: Fix double free " Sasha Levin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox