Re: [PATCH] [PATCH RESEND] drm/virtio: fix memory leak of vbuf

From: Dmitry Osipenko
Date: Tue Jul 23 2024 - 11:52:38 EST


On 5/9/24 04:52, Weishi Li wrote:
> @@ -356,12 +356,14 @@ static int virtio_gpu_queue_ctrl_sgs(struct virtio_gpu_device *vgdev,
>
> ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC);
> WARN_ON(ret);
> + if (ret < 0 && ret != -ENOSPC) {
> + free_vbuf(vgdev, vbuf);

Don't see why -ENOSPC shouldn't free buffer. If you trying to fix a
theoretical leak, then not worth doing it, IMO. Not apparent how to test
this error code path and it's not easy to review it.

--
Best regards,
Dmitry