Whamcloud - gitweb
LU-3426 build: fix 'resource leak' errors 09/6509/5
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 31 May 2013 13:47:36 +0000 (15:47 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 25 Jul 2013 03:16:43 +0000 (03:16 +0000)
Fix 'resource leak' defects found by Coverity version 6.5.1:
Resource leak (RESOURCE_LEAK)
Variable going out of scope leaks the storage it points to.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: Ieb45e4cceb26b6c1ca605ef1b1c78cf3f603dffa
Reviewed-on: http://review.whamcloud.com/6509
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/linux/linux-curproc.c
lustre/ost/ost_handler.c

index 9ebccb8..313c012 100644 (file)
@@ -275,8 +275,10 @@ int cfs_get_environ(const char *key, char *value, int *val_len)
         * which is already holding mmap_sem for writes.  If some other
         * thread gets the write lock in the meantime, this thread will
         * block, but at least it won't deadlock on itself.  LU-1735 */
-       if (down_read_trylock(&mm->mmap_sem) == 0)
+       if (down_read_trylock(&mm->mmap_sem) == 0) {
+               kfree(buffer);
                return -EDEADLK;
+       }
        up_read(&mm->mmap_sem);
 
        addr = mm->env_start;
index 5b7e34e..adc9304 100644 (file)
@@ -1348,8 +1348,10 @@ static int lock_region(struct obd_export *exp, struct obdo *oa,
                return -ENOMEM;
 
        rc = ost_lock_get(exp, oa, begin, end - begin, &region->lh, LCK_PR, 0);
-       if (rc)
+       if (rc) {
+               OBD_FREE_PTR(region);
                return rc;
+       }
 
        CDEBUG(D_OTHER, "ost lock [%llu,%llu], lh=%p\n",
               begin, end, &region->lh);