Skip to contentSkip to conversation

drm/virtio: Fix a double free in virtio_gpu_cmd_map()

PATCH Applied Dan Carpenter 3 participants 3 messages Oct 30, 2020 – Nov 6, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/virtio: Fix a double free in virtio_gpu_cmd_map()

This is freed both here and in the caller (virtio_gpu_vram_map()) so it's a double free. The correct place is only in the caller.

Fixes 16845c5d5409 ("drm/virtio: implement blob resources: implement vram object")
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +1 -3
index 72586cd8cc4c..3f200306c9d7 100644
@@ -1212,10 +1212,8 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
 	struct virtio_gpu_resp_map_info *resp_buf;
 
 	resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
-	if (!resp_buf) {
-		virtio_gpu_array_put_free(objs);
+	if (!resp_buf)
 		return -ENOMEM;
-	}
 
 	cmd_p = virtio_gpu_alloc_cmd_resp
 		(vgdev, virtio_gpu_cmd_resource_map_cb, &vbuf, sizeof(*cmd_p),
Signature · 1 line
2.28.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Dan Carpenter

This is freed both here and in the caller (virtio_gpu_vram_map()) so it's a double free. The correct place is only in the caller.

Fixes 16845c5d5409 ("drm/virtio: implement blob resources: implement vram

object")

---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/virtio/virtgpu_vq.c +1 -3
index 72586cd8cc4c..3f200306c9d7 100644
@@ -1212,10 +1212,8 @@ int virtio_gpu_cmd_map(struct virtio_gpu_device
 *vgdev,
        struct virtio_gpu_resp_map_info *resp_buf;
 
        resp_buf = kzalloc(sizeof(*resp_buf), GFP_KERNEL);
-       if (!resp_buf) {
-               virtio_gpu_array_put_free(objs);
+       if (!resp_buf)
                return -ENOMEM;
-       }
 
        cmd_p = virtio_gpu_alloc_cmd_resp
Quoted 5 lines

(vgdev, virtio_gpu_cmd_resource_map_cb, &vbuf,
sizeof(*cmd_p),
--
2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

This is freed both here and in the caller (virtio_gpu_vram_map()) so it's a double free. The correct place is only in the caller.

Fixes 16845c5d5409 ("drm/virtio: implement blob resources: implement vram object")

Pushed to drm-misc-next.

thanks,
Gerd