[ovs-dev] [PATCH] ovn-nbctl: Fix memory leak reported by Valgrind.

William Tu u9012063 at gmail.com
Sat May 14 23:12:30 UTC 2016


thank you. I submit patch v2 here:
https://patchwork.ozlabs.org/patch/622297/

On Sat, May 14, 2016 at 11:46 AM, Ben Pfaff <blp at ovn.org> wrote:

> On Fri, May 13, 2016 at 11:30:14PM -0700, William Tu wrote:
> > Hi Ryan,
> >
> > Thanks for the feedback.
> >
> > > --- a/ovn/utilities/ovn-sbctl.c
> > > > +++ b/ovn/utilities/ovn-sbctl.c
> > > > @@ -973,6 +973,7 @@ do_sbctl(const char *args, struct ctl_command
> > > > *commands, size_t n_commands,
> > > >      free(commands);
> > > >      ovsdb_idl_txn_destroy(txn);
> > > >      ovsdb_idl_destroy(idl);
> > > > +    free(CONST_CAST(char *, args));
> > > >
> > > >      exit(EXIT_SUCCESS);
> > >
> > > Actually I don't understand why valgrind reports "definitely lost"
> here.
> > If the process is about to exit(), and we still have access to pointers
> > pointing to un-free memory (ex: args), valgrind should report as "still
> > reachable", not "definitely lost".
> >
> >
> > > While this will work, my preference in both cases would be to make
> > > the call to free from inside the main block, so that the same
> > > block allocates the memory and then frees it.
> > >
> > >
> > The main block is an infinite "for (;;)" and program exits only at
> > do_nbctl(). I couldn't find a way to call the free inside the main loop.
> Do
> > you have any suggestion?
>
> Just make do_nbctl() return a success indication, then the caller can
> exit if it succeeds.
>



More information about the dev mailing list