g_return_if_fail(), g_return_val_if_fail() misuse
cover g_return_if_fail(), g_return_val_if_fail() misuse
Markus Armbruster (2):
backends/dbus-vmstate: Fix short read error handling
vhost_user_gpu: Drop dead check for g_malloc() failure
backends/dbus-vmstate.c | 5 ++++- hw/display/vhost-user-gpu.c | 1 - 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 backends/dbus-vmstate: Fix short read error handling
When dbus_vmstate_post_load() fails, it complains to stderr. Except on short read, where it checks with g_return_val_if_fail(). This fails silently if G_DISABLE_CHECKS is undefined (it should be), or else pads the short read with uninitialized bytes.
Replace g_return_val_if_fail() by a proper error check.
--- backends/dbus-vmstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
backends/dbus-vmstate.c +4 -1
@@ -229,7 +229,10 @@ static int dbus_vmstate_post_load(void *opaque, int version_id) &bytes_read, NULL, &err)) { goto error; } -g_return_val_if_fail (bytes_read == len,-1 ); +if (bytes_read != len) { +error_report ("%s: Short read" , __func__); +return -1 ; + } id[len] =0 ;trace_dbus_vmstate_loading (id);
Signature · 1 line
2.26.2
Re: [PATCH 1/2] backends/dbus-vmstate: Fix short read error handling
Quoted 10 lines · Markus Armbruster
When
dbus_vmstate_post_load()fails, it complains to stderr. Except on short read, where it checks withg_return_val_if_fail(). This fails silently ifG_DISABLE_CHECKSis undefined (it should be), or else pads the short read with uninitialized bytes.Replace
g_return_val_if_fail()by a proper error check.Fixes 5010cec2bc87dafab39b3913c8ca91f88df9c540Signed-off-by Markus Armbruster <[email protected]>
thanks
Quoted 24 lines
--- backends/dbus-vmstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)backends/dbus-vmstate.c +4
-2@@ -229,7 +229,10 @@ static int dbus_vmstate_post_load(void *opaque, int version_id) &bytes_read, NULL, &err)) { goto error; } -g_return_val_if_fail (bytes_read == len,-1 ); +if (bytes_read != len) { +error_report ("%s: Short read" , __func__); +return -1 ; + } id[len] =0 ;trace_dbus_vmstate_loading (id); --2.26.2
Signature · 1 line
Marc-André Lureau
Laurent Vivier
AppliedRe: [PATCH 1/2] backends/dbus-vmstate: Fix short read error handling
In reply to Markus ArmbrusterLe 26/01/2021 à 13:42, Markus Armbruster a écrit :
Quoted 20 lines
When
dbus_vmstate_post_load()fails, it complains to stderr. Except on short read, where it checks withg_return_val_if_fail(). This fails silently ifG_DISABLE_CHECKSis undefined (it should be), or else pads the short read with uninitialized bytes.Replace
g_return_val_if_fail()by a proper error check.Fixes 5010cec2bc87dafab39b3913c8ca91f88df9c540Signed-off-by Markus Armbruster <[email protected]>--- backends/dbus-vmstate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)backends/dbus-vmstate.c +0
-0@@ -229,7 +229,10 @@ static int dbus_vmstate_post_load(void *opaque, int version_id) &bytes_read, NULL, &err)) {
backends/dbus-vmstate.c static int dbus_vmstate_post_load(void *opaque, int version_id) · line 238
Quoted 10 lines
backends/dbus-vmstate.c +4
-1goto error; } -g_return_val_if_fail (bytes_read == len,-1 ); +if (bytes_read != len) { +error_report ("%s: Short read" , __func__); +return -1 ; + } id[len] =0 ;trace_dbus_vmstate_loading (id);
Applied to my trivial-patches branch.
Thanks,
Laurent
PATCH 2/2 vhost_user_gpu: Drop dead check for g_malloc() failure
In reply to Markus Armbruster--- hw/display/vhost-user-gpu.c | 1 - 1 file changed, 1 deletion(-)
hw/display/vhost-user-gpu.c +0 -1
@@ -332,7 +332,6 @@ vhost_user_gpu_chr_read(void *opaque) } msg =g_malloc (VHOST_USER_GPU_HDR_SIZE + size); -g_return_if_fail (msg !=NULL ); r =qemu_chr_fe_read_all (&g->vhost_chr, (uint8_t *)&msg->payload, size);
Signature · 1 line
2.26.2
Re: [PATCH 2/2] vhost_user_gpu: Drop dead check for g_malloc() failure
Quoted 2 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
thanks
Quoted 20 lines
--- hw/display/vhost-user-gpu.c | 1 - 1 file changed, 1 deletion(-)hw/display/vhost-user-gpu.c +0
-2@@ -332,7 +332,6 @@ vhost_user_gpu_chr_read(void *opaque) } msg =g_malloc (VHOST_USER_GPU_HDR_SIZE + size); -g_return_if_fail (msg !=NULL ); r =qemu_chr_fe_read_all (&g->vhost_chr, (uint8_t *)&msg->payload, size); --2.26.2
Signature · 1 line
Marc-André Lureau
Re: [PATCH 2/2] vhost_user_gpu: Drop dead check for g_malloc() failure
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>
Quoted 18 lines
--- hw/display/vhost-user-gpu.c | 1 - 1 file changed, 1 deletion(-)hw/display/vhost-user-gpu.c +0
-1@@ -332,7 +332,6 @@ vhost_user_gpu_chr_read(void *opaque) } msg =g_malloc (VHOST_USER_GPU_HDR_SIZE + size); -g_return_if_fail (msg !=NULL ); r =qemu_chr_fe_read_all (&g->vhost_chr, (uint8_t *)&msg->payload, size);Signature · 1 line
2.26.2
Laurent Vivier
AppliedRe: [PATCH 2/2] vhost_user_gpu: Drop dead check for g_malloc() failure
In reply to Markus ArmbrusterLe 26/01/2021 à 13:42, Markus Armbruster a écrit :
Quoted 11 lines
Signed-off-by Markus Armbruster <[email protected]>--- hw/display/vhost-user-gpu.c | 1 - 1 file changed, 1 deletion(-)hw/display/vhost-user-gpu.c +0
-0
hw/display/vhost-user-gpu.c vhost_user_gpu_chr_read(void *opaque) · line 337
Quoted 7 lines
hw/display/vhost-user-gpu.c +0
-1@@ -332,7 +332,6 @@ vhost_user_gpu_chr_read(void *opaque) } msg =g_malloc (VHOST_USER_GPU_HDR_SIZE + size); -g_return_if_fail (msg !=NULL ); r =qemu_chr_fe_read_all (&g->vhost_chr, (uint8_t *)&msg->payload, size);
Applied to my trivial-patches branch.
Thanks,
Laurent
I think this could go via qemu-trivial.
Quoted 7 lines · Markus Armbruster
Markus Armbruster (2):
backends/dbus-vmstate: Fix short read error handling
vhost_user_gpu: Drop dead check forg_malloc()failurebackends/dbus-vmstate.c | 5 ++++- hw/display/vhost-user-gpu.c | 1 - 2 files changed, 4 insertions(+), 2 deletions(-)