diff mbox series

[2/7] vhost-user-gpu: fix resource leak in 'vg_resource_create_2d'

Message ID 20210505045824.33880-3-liq3ea@163.com (mailing list archive)
State New, archived
Headers show
Series vhost-user-gpu: fix several security issues | expand

Commit Message

Li Qiang May 5, 2021, 4:58 a.m. UTC
Call 'vugbm_buffer_destroy' in error path to avoid resource leak.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 contrib/vhost-user-gpu/vhost-user-gpu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Prasad Pandit May 5, 2021, 7:28 a.m. UTC | #1
+-- On Tue, 4 May 2021, Li Qiang wrote --+
| Call 'vugbm_buffer_destroy' in error path to avoid resource leak.
| 
| Signed-off-by: Li Qiang <liq3ea@163.com>
| ---
|  contrib/vhost-user-gpu/vhost-user-gpu.c | 1 +
|  1 file changed, 1 insertion(+)
| 
| diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
| index f73f292c9f..b5e153d0d6 100644
| --- a/contrib/vhost-user-gpu/vhost-user-gpu.c
| +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
| @@ -349,6 +349,7 @@ vg_resource_create_2d(VuGpu *g,
|          g_critical("%s: resource creation failed %d %d %d",
|                     __func__, c2d.resource_id, c2d.width, c2d.height);
|          g_free(res);
| +        vugbm_buffer_destroy(&res->buffer);
|          cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
|          return;
|      }

* Looks good.

Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>

Thank you.
--
 - P J P
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D
diff mbox series

Patch

diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
index f73f292c9f..b5e153d0d6 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -349,6 +349,7 @@  vg_resource_create_2d(VuGpu *g,
         g_critical("%s: resource creation failed %d %d %d",
                    __func__, c2d.resource_id, c2d.width, c2d.height);
         g_free(res);
+        vugbm_buffer_destroy(&res->buffer);
         cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY;
         return;
     }