drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
Subsystems (4)
PATCH 1/1 drm/virtio: Fix NULL vs IS_ERR checking in virtio_gpu_object_shmem_init
Since drm_prime_pages_to_sg() function return error pointers. The drm_gem_shmem_get_sg_table() function returns error pointers too. Using IS_ERR() to check the return value to fix this.
Fixes f651c8b05542("drm/virtio: factor out the sg_table from virtio_gpu_object")
Signed-off-by Miaoqian Lin <[email protected]>
--- drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_object.c +2 -2
@@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,* since virtio_gpu doesn't support dma-buf import from other devices. */ shmem->pages =drm_gem_shmem_get_sg_table (&bo->base.base); -if (!shmem->pages) { +if (IS_ERR (shmem->pages)) {drm_gem_shmem_unpin (&bo->base.base); -return -EINVAL ; +return PTR_ERR (shmem->pages); }if (use_dma_api) {
Signature · 1 line
2.17.1
Quoted 8 lines · Miaoqian Lin
Since
drm_prime_pages_to_sg()function return error pointers. Thedrm_gem_shmem_get_sg_table()function returns error pointers too. UsingIS_ERR()to check the return value to fix this.Fixes f651c8b05542("drm/virtio: factor out the sg_table from
virtio_gpu_object")Signed-off-by Miaoqian Lin <[email protected]>
Reviewed-by Gurchetan Singh <[email protected]>
Quoted 27 lines
--- drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/virtio/virtgpu_object.c +0
-0@@ -168,9 +168,9 @@ static int virtio_gpu_object_shmem_init(structvirtio_gpu_device *vgdev, * since virtio_gpu doesn't support dma-buf import from otherdevices.
*/ shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);drivers/gpu/drm/virtio/virtgpu_object.c +2
-3-if (!shmem->pages) { +if (IS_ERR (shmem->pages)) {drm_gem_shmem_unpin (&bo->base.base); -return -EINVAL ; +return PTR_ERR (shmem->pages); }if (use_dma_api) { --2.17.1