qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 3/3] spapr: fix memory leak in spapr_memory_pre_


From: Greg Kurz
Subject: Re: [Qemu-devel] [PATCH 3/3] spapr: fix memory leak in spapr_memory_pre_plug()
Date: Tue, 6 Jun 2017 17:55:09 +0200

On Tue, 6 Jun 2017 17:43:13 +0200
Thomas Huth <address@hidden> wrote:

> On 06.06.2017 17:22, Greg Kurz wrote:
> > The string returned by object_property_get_str() is dynamically allocated.
> > 
> > (Spotted by Coverity, CID 1375942)
> > 
> > Signed-off-by: Greg Kurz <address@hidden>
> > ---
> >  hw/ppc/spapr.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> > index 86e622834f63..f834a6a7dfac 100644
> > --- a/hw/ppc/spapr.c
> > +++ b/hw/ppc/spapr.c
> > @@ -2617,8 +2617,11 @@ static void spapr_memory_pre_plug(HotplugHandler 
> > *hotplug_dev, DeviceState *dev,
> >      if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) {
> >          error_setg(errp, "Memory backend has bad page size. "
> >                     "Use 'memory-backend-file' with correct mem-path.");
> > -        return;
> > +        goto out;
> >      }
> > +
> > +out:
> > +    g_free(mem_dev);
> >  }  
> 
> You don't need the goto and the "out" label here.
> 
>  Thomas

I did it on purpose, so that someone may add some code to this
function and doesn't need to care for the freeing... but of
course, we can simply:

-        return;
     }
+    g_free(mem_dev);
}  

Attachment: pgpQxgcFTB7n8.pgp
Description: OpenPGP digital signature


reply via email to

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