On Mon, Jan 05, 2009 at 08:39:56PM +0530, Balbir Singh wrote:
> * Dhaval Giani <[email protected]> [2009-01-04 22:29:37]:
> 
> > The cgroup_modify_cgroup uninitialized error is fixed in the clean up
> > patches.
> > 
> > After this patch, there are no leaks in the library as per the test
> > cases and valgrind. (The cgroup data structure has to be explictly
> > freed by the caller, so it is not a leak in the library)
> > 
> > Signed-off-by: Dhaval Giani <[email protected]>
> > ---
> >  api.c |   20 +++++++++++++++++---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> > 
> > Index: trunk/api.c
> > ===================================================================
> > --- trunk.orig/api.c        2009-01-04 22:18:44.000000000 +0530
> > +++ trunk/api.c     2009-01-04 22:22:19.000000000 +0530
> > @@ -562,11 +562,17 @@ int cgroup_init()
> >      *
> >      * XX: fix the size for fgets
> >      */
> > -   buf = fgets(subsys_name, FILENAME_MAX, proc_cgroup);
> > +   buf = malloc(FILENAME_MAX);
> > +   if (!buf) {
> > +           ret = ECGOTHER;
> > +           goto unlock_exit;
> > +   }
> > +   buf = fgets(buf, FILENAME_MAX, proc_cgroup);
> >     if (!buf) {
> >             ret = EIO;
> >             goto unlock_exit;
> >     }
> > +   free(buf);
> > 
> >     while (!feof(proc_cgroup)) {
> >             err = fscanf(proc_cgroup, "%s %d %d %d", subsys_name,
> > @@ -578,7 +584,6 @@ int cgroup_init()
> >             i++;
> >     }
> >     controllers[i] = NULL;
> > -   fclose(proc_cgroup);
> > 
> >     proc_mount = fopen("/proc/mounts", "r");
> >     if (proc_mount == NULL) {
> > @@ -632,10 +637,18 @@ int cgroup_init()
> >     found_mnt++;
> >     cg_mount_table[found_mnt].name[0] = '\0';
> > 
> > -   fclose(proc_mount);
> >     cgroup_initialized = 1;
> > 
> >  unlock_exit:
> > +   if (proc_cgroup)
> > +           fclose(proc_cgroup);
> > +
> > +   if (proc_mount)
> > +           fclose(proc_mount);
> > +
> > +   for (i = 0; controllers[i]; i++)
> > +           free(controllers[i]);
> > +
> >     pthread_rwlock_unlock(&cg_mount_table_lock);
> >     return ret;
> >  }
> > @@ -847,6 +860,7 @@ static int cg_mkdir_p(const char *path)
> >     char cwd[FILENAME_MAX], *buf;
> > 
> >     buf = getcwd(cwd, FILENAME_MAX);
> > +
> >     if (!buf)
> >             return ECGOTHER;
> >
> 
> Looks good
> 
> Acked-by: Balbir Singh <[email protected]> 
> 

Thanks Balbir, I merged this in

> -- 
>       Balbir

-- 
regards,
Dhaval

------------------------------------------------------------------------------
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to