qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] [RFC PATCH v1 1/6] migration: Fix unregister_savevm()


From: David Gibson
Subject: Re: [Qemu-ppc] [RFC PATCH v1 1/6] migration: Fix unregister_savevm()
Date: Wed, 17 May 2017 16:43:00 +1000
User-agent: Mutt/1.8.0 (2017-02-23)

On Wed, May 17, 2017 at 09:19:17AM +0530, Bharata B Rao wrote:
> In unregister_savevm(), free se->compat only if it was allocated earlier.
> 
> Signed-off-by: Bharata B Rao <address@hidden>

I don't think this is necessary.  If se->compat was never allocated,
then it should be NULL (since se is allocated with g_new0()).
g_free() is explicitly safe to call on NULL, and we already rely on
that in qemu.

> ---
>  migration/savevm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 352a8f2..7a268ec 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -648,7 +648,9 @@ void unregister_savevm(DeviceState *dev, const char 
> *idstr, void *opaque)
>      QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
>          if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
>              QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
> -            g_free(se->compat);
> +            if (dev) {
> +                g_free(se->compat);
> +            }
>              g_free(se->ops);
>              g_free(se);
>          }

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]