Patchwork [v3,resend/cleanup,2/8] rdma: bugfix: ram_control_save_page()

login
register
mail settings
Submitter mrhines@linux.vnet.ibm.com
Date July 12, 2013, 2:40 p.m.
Message ID <1373640028-5138-3-git-send-email-mrhines@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/258754/
State New
Headers show

Comments

mrhines@linux.vnet.ibm.com - July 12, 2013, 2:40 p.m.
From: "Michael R. Hines" <mrhines@us.ibm.com>

We were not checking for a valid 'bytes_sent' pointer before accessing it.

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
---
 savevm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Eric Blake - July 12, 2013, 5:09 p.m.
On 07/12/2013 08:40 AM, mrhines@linux.vnet.ibm.com wrote:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
> 
> We were not checking for a valid 'bytes_sent' pointer before accessing it.
> 
> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
> ---
>  savevm.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/savevm.c b/savevm.c
> index e0491e7..03fc4d9 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -662,7 +662,7 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
>                                      offset, size, bytes_sent);
>  
>          if (ret != RAM_SAVE_CONTROL_DELAYED) {
> -            if (*bytes_sent > 0) {
> +            if (bytes_sent && *bytes_sent > 0) {
>                  qemu_update_position(f, *bytes_sent);
>              } else if (ret < 0) {
>                  qemu_file_set_error(f, ret);
>

Patch

diff --git a/savevm.c b/savevm.c
index e0491e7..03fc4d9 100644
--- a/savevm.c
+++ b/savevm.c
@@ -662,7 +662,7 @@  size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset,
                                     offset, size, bytes_sent);
 
         if (ret != RAM_SAVE_CONTROL_DELAYED) {
-            if (*bytes_sent > 0) {
+            if (bytes_sent && *bytes_sent > 0) {
                 qemu_update_position(f, *bytes_sent);
             } else if (ret < 0) {
                 qemu_file_set_error(f, ret);