diff mbox

[v2] migration: don't use uninitialized variables

Message ID 1375141192-1121-1-git-send-email-p.pawit@gmail.com
State New
Headers show

Commit Message

Pawit Pornkitprasan July 29, 2013, 11:39 p.m. UTC
The qmp_migrate method uses the 'blk' and 'inc' parameter without
checking if they're valid or not (they may be uninitialized if
command is received via QMP)

Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
---
 migration.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Blake July 30, 2013, 12:34 p.m. UTC | #1
On 07/29/2013 05:39 PM, Pawit Pornkitprasan wrote:
> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>
> ---
>  migration.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

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

> 
> diff --git a/migration.c b/migration.c
> index 9fc7294..57a7998 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -399,8 +399,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;
>  
>      if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);
>
Luiz Capitulino July 30, 2013, 1:31 p.m. UTC | #2
On Tue, 30 Jul 2013 08:39:52 +0900
Pawit Pornkitprasan <p.pawit@gmail.com> wrote:

> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <p.pawit@gmail.com>

Applied to the qmp branch, thanks.

> ---
>  migration.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 9fc7294..57a7998 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -399,8 +399,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;
>  
>      if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);
diff mbox

Patch

diff --git a/migration.c b/migration.c
index 9fc7294..57a7998 100644
--- a/migration.c
+++ b/migration.c
@@ -399,8 +399,8 @@  void qmp_migrate(const char *uri, bool has_blk, bool blk,
     MigrationParams params;
     const char *p;
 
-    params.blk = blk;
-    params.shared = inc;
+    params.blk = has_blk && blk;
+    params.shared = has_inc && inc;
 
     if (s->state == MIG_STATE_ACTIVE || s->state == MIG_STATE_SETUP) {
         error_set(errp, QERR_MIGRATION_ACTIVE);