pcp
[Top] [All Lists]

[patch] memory leak in xfs project quotas

To: pcp@xxxxxxxxxxx
Subject: [patch] memory leak in xfs project quotas
From: Martin Hicks <mort@xxxxxxx>
Date: Wed, 6 May 2009 14:16:13 -0500
User-agent: Mutt/1.5.17 (2007-11-01)
In the linux PMDA.  Any complaints with this patch?

The changes at the beginning just get rid of whitespace annoyances.
The last two hunks are what fix the problem.

thanks
mh

diff --git a/src/pmdas/linux/filesys.c b/src/pmdas/linux/filesys.c
index 033da2e..a16abfc 100644
--- a/src/pmdas/linux/filesys.c
+++ b/src/pmdas/linux/filesys.c
@@ -26,15 +26,15 @@
 static void 
 refresh_filesys_projects(pmInDom qindom, filesys_t *fs)
 {
-    char               buffer[MAXPATHLEN];
+    char               buffer[MAXPATHLEN];
     project_t          *qp;
     fs_quota_stat_t    s;
     fs_disk_quota_t    d;
     size_t             idsz, devsz;
     FILE               *projects;
-    char               *p, *idend;
-    uint32_t           prid;
-    int                qcmd, sts;
+    char               *p, *idend;
+    uint32_t           prid;
+    int                        qcmd, sts;
 
     qcmd = QCMD(Q_XGETQSTAT, XQM_PRJQUOTA);
     if (quotactl(qcmd, fs->device, 0, (void*)&s) < 0)
@@ -75,7 +75,7 @@ refresh_filesys_projects(pmInDom qindom, filesys_t *fs)
        qp = NULL;
        sts = pmdaCacheLookupName(qindom, p, NULL, (void **)&qp);
        if (sts == PMDA_CACHE_ACTIVE)   /* repeated line in /etc/projects? */
-           continue;
+           goto next;
        if (sts != PMDA_CACHE_INACTIVE) {
            qp = (project_t *)malloc(sizeof(project_t));
 #if PCP_DEBUG
@@ -92,6 +92,8 @@ refresh_filesys_projects(pmInDom qindom, filesys_t *fs)
        qp->files_used = d.d_icount;
        qp->files_time_left = d.d_itimer;
        pmdaCacheStore(qindom, PMDA_CACHE_ADD, p, (void *)qp);
+next:
+       free(p);
     }
     fclose(projects);
 }


<Prev in Thread] Current Thread [Next in Thread>