Skip to contentSkip to conversation

virtio-gpu: fix potential divide-by-zero regression

PATCH In review [email protected] 4 participants 4 messages Jul 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-gpu: fix potential divide-by-zero regression

From: Marc-André Lureau <[email protected]>

Commit 9462ff4695aa0 ("virtio-gpu/win32: allocate shareable 2d resources/images") introduces a division, which can lead to crashes when "height" is 0.

---
 hw/display/virtio-gpu.c  | 4 ++--
 tests/lcitool/libvirt-ci | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/display/virtio-gpu.c +2 -2
index 347e17d490..7371a5cbf0 100644
@@ -324,7 +324,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g,
         res->image = pixman_image_create_bits(pformat,
                                               c2d.width,
                                               c2d.height,
-                                              bits, res->hostmem / c2d.height);
+                                              bits, c2d.height ? res->hostmem / c2d.height : 0);
 #ifdef WIN32
         if (res->image) {
             pixman_image_set_destroy_function(res->image, win32_pixman_image_destroy, res->handle);
@@ -1292,7 +1292,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
 #endif
         res->image = pixman_image_create_bits(pformat,
                                               res->width, res->height,
-                                              bits, res->hostmem / res->height);
+                                              bits, res->height ? res->hostmem / res->height : 0);
         if (!res->image) {
             g_free(res);
             return -EINVAL;
tests/lcitool/libvirt-ci +1 -1
index b0f44f929a..c8971e90ac 160000
@@ -1 +1 @@
-Subproject commit b0f44f929a81c0a604fb7fbf8afc34d37ab0eae9
+Subproject commit c8971e90ac169ee2b539c747f74d96c876debdf9
Signature · 1 line
2.41.0
#1 lore raw
Quoted 9 lines · On 04/07/2023 11.19, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Commit 9462ff4695aa0 ("virtio-gpu/win32: allocate shareable 2d resources/images") introduces a division, which can lead to crashes when "height" is 0.

---

...

tests/lcitool/libvirt-ci line 1

Quoted 7 lines
tests/lcitool/libvirt-ci +1 -1
index b0f44f929a..c8971e90ac 160000
@@ -1 +1 @@
-Subproject commit b0f44f929a81c0a604fb7fbf8afc34d37ab0eae9
+Subproject commit c8971e90ac169ee2b539c747f74d96c876debdf9

That submodule update looks like an accident?

Thomas

#2 lore raw
Quoted 11 lines · Thomas Huth
Quoted 9 lines · On 04/07/2023 11.19, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Commit 9462ff4695aa0 ("virtio-gpu/win32: allocate shareable 2d resources/images") introduces a division, which can lead to crashes when "height" is 0.

---

...

Quoted 11 lines

tests/lcitool/libvirt-ci line 1

Quoted 7 lines
tests/lcitool/libvirt-ci +1 -1
index b0f44f929a..c8971e90ac 160000
@@ -1 +1 @@
-Subproject commit b0f44f929a81c0a604fb7fbf8afc34d37ab0eae9
+Subproject commit c8971e90ac169ee2b539c747f74d96c876debdf9

That submodule update looks like an accident?

Oops.. thanks for noticing

Signature · 1 line
Marc-André Lureau
Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On 230704 1119, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Commit 9462ff4695aa0 ("virtio-gpu/win32: allocate shareable 2d resources/images") introduces a division, which can lead to crashes when "height" is 0.