From: Sebastien Buisson Date: Fri, 31 May 2013 13:47:36 +0000 (+0200) Subject: LU-3426 build: fix 'resource leak' errors X-Git-Tag: 2.4.53~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F6509%2F5;p=fs%2Flustre-release.git LU-3426 build: fix 'resource leak' errors 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 Signed-off-by: Dmitry Eremin Change-Id: Ieb45e4cceb26b6c1ca605ef1b1c78cf3f603dffa Reviewed-on: http://review.whamcloud.com/6509 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin --- diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index 9ebccb8..313c012 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -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; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 5b7e34e..adc9304 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -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, ®ion->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, ®ion->lh);