[ovs-dev] [PATCH] ovs-thread: Fix memory leak in thread exit.

Ben Pfaff blp at ovn.org
Tue Nov 10 21:57:33 UTC 2015


OK, let's try adding one more line, does it get through?

    Signed-off-by: Ben Pfaff <blp at ovn.org>

On Tue, Nov 10, 2015 at 01:54:30PM -0800, Ben Pfaff wrote:
> There was supposed to be a commit message with this, but when I include
> it the list refuses to post it.  Let's try part of it again, to narrow
> it down:
> 
>     'n' is the number of keys, which are grouped into blocks of L2_SIZE
>     indexes.  Even if only one key in a block is allocated, the whole block has
>     a pointer to it that must be freed.  Thus, we need to round up instead of
>     down.
> 
> On Tue, Nov 10, 2015 at 01:50:58PM -0800, Ben Pfaff wrote:
> > diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
> > index 88b92d1..2f6bc58 100644
> > --- a/lib/ovs-thread.c
> > +++ b/lib/ovs-thread.c
> > @@ -665,7 +665,7 @@ ovsthread_key_destruct__(void *slots_)
> >      n = n_keys;
> >      ovs_mutex_unlock(&key_mutex);
> >  
> > -    for (i = 0; i < n / L2_SIZE; i++) {
> > +    for (i = 0; i < DIV_ROUND_UP(n, L2_SIZE); i++) {
> >          free(slots->p1[i]);
> >      }
> >      free(slots);
> > -- 
> > 2.1.3
> > 



More information about the dev mailing list