From 20333145e85b275d172ea91aaa9c848fd9c90271 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 31 May 2013 15:47:36 +0200 Subject: [PATCH] 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 --- libcfs/libcfs/linux/linux-curproc.c | 4 +++- lustre/ost/ost_handler.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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); -- 1.8.3.1