diff mbox series

[v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init()

Message ID 20211118111632.GE1147@kili (mailing list archive)
State New, archived
Headers show
Series [v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init() | expand

Commit Message

Dan Carpenter Nov. 18, 2021, 11:16 a.m. UTC
The drm_gem_shmem_get_sg_table() function never returns NULL.  It returns
error pointers on error.

Fixes: c66df701e783 ("drm/virtio: switch from ttm to gem shmem helpers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: I originally sent this patch on 19 Jun 2020 but it was somehow
    not applied.  As I review it now, I see that the bug is actually
    older than I originally thought and so I have updated the Fixes
    tag.

 drivers/gpu/drm/virtio/virtgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Chia-I Wu Nov. 23, 2021, 6:47 p.m. UTC | #1
On Thu, Nov 18, 2021 at 3:16 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The drm_gem_shmem_get_sg_table() function never returns NULL.  It returns
> error pointers on error.
>
> Fixes: c66df701e783 ("drm/virtio: switch from ttm to gem shmem helpers")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: I originally sent this patch on 19 Jun 2020 but it was somehow
>     not applied.  As I review it now, I see that the bug is actually
>     older than I originally thought and so I have updated the Fixes
>     tag.
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index f648b0e24447..8bb80289672c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -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) {