virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init()
@ 2021-11-18 11:16 Dan Carpenter
  2021-11-23 18:47 ` Chia-I Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-11-18 11:16 UTC (permalink / raw)
  To: David Airlie, Gerd Hoffmann
  Cc: dri-devel, kernel-janitors, Chia-I Wu, Daniel Vetter,
	virtualization

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(-)

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) {
-- 
2.20.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init()
  2021-11-18 11:16 [PATCH v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init() Dan Carpenter
@ 2021-11-23 18:47 ` Chia-I Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Chia-I Wu @ 2021-11-23 18:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, kernel-janitors, ML dri-devel,
	open list:VIRTIO CORE, NET AND BLOCK DRIVERS, Daniel Vetter

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>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-23 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-18 11:16 [PATCH v2] drm/virtio: Fix an NULL vs IS_ERR() bug in virtio_gpu_object_shmem_init() Dan Carpenter
2021-11-23 18:47 ` Chia-I Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).