Whamcloud - gitweb
LU-2644 build: fix 'resource leak' errors
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 18 Jan 2013 15:00:40 +0000 (16:00 +0100)
committerOleg Drokin <green@whamcloud.com>
Sat, 26 Jan 2013 02:55:11 +0000 (21:55 -0500)
Fix 'resource leak' defects found by Coverity version 6.0.3:
Resource leak (RESOURCE_LEAK)
Variable going out of scope leaks the storage it points to.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: I9fae1905848a83393b7258449bfafd1fc0a342a7
Reviewed-on: http://review.whamcloud.com/5131
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/namei.c
lustre/lov/lov_obd.c
lustre/mgc/mgc_request.c
lustre/obdclass/obd_mount.c
lustre/osd-ldiskfs/osd_quota_fmt.c
lustre/utils/liblustreapi.c

index 3622909..6f897e3 100644 (file)
@@ -1202,12 +1202,12 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
         rc = obd_destroy(NULL, ll_i2dtexp(dir), oa, lsm, &oti,
                          ll_i2mdexp(dir), oc);
         capa_put(oc);
-        OBDO_FREE(oa);
         if (rc)
                 CERROR("obd destroy objid "LPX64" error %d\n",
                        lsm->lsm_object_id, rc);
  out_free_memmd:
         obd_free_memmd(ll_i2dtexp(dir), &lsm);
+       OBDO_FREE(oa);
  out:
         return rc;
 }
index 838e713..3c5738a 100644 (file)
@@ -2269,7 +2269,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
        fm_end_offset = fiemap_calc_fm_end_offset(fiemap, lsm, fm_start,
                                                  fm_end, &start_stripe);
        if (fm_end_offset == -EINVAL)
-               return -EINVAL;
+               GOTO(out, rc = -EINVAL);
 
         if (fiemap->fm_extent_count == 0) {
                 get_num_extents = 1;
index 0c2f107..4550de5 100644 (file)
@@ -1264,8 +1264,10 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
         } else {
                LASSERT(IS_MDT(lsi));
                rc = server_name2svname(lsi->lsi_svname, inst, NULL);
-               if (rc)
+               if (rc) {
+                       OBD_FREE(inst, CFS_PAGE_SIZE);
                        RETURN(-EINVAL);
+               }
                pos = strlen(inst);
         }
 
index 3eaf93f..411efa2 100644 (file)
@@ -969,6 +969,7 @@ int lustre_register_osp_item(char *ospname, struct obd_export **exp,
                OBD_ALLOC_PTR(uuid);
                if (uuid == NULL) {
                        mutex_unlock(&osp_register_list_lock);
+                       OBD_FREE_PTR(ori);
                        RETURN(-ENOMEM);
                }
                memcpy(uuid->uuid, ospname, strlen(ospname));
@@ -1178,7 +1179,7 @@ static int lustre_osp_add_conn(struct lustre_cfg *cfg,
 
        OBD_ALLOC_PTR(bufs);
        if (bufs == NULL)
-               RETURN(-ENOMEM);
+               GOTO(out, rc = -ENOMEM);
 
        lustre_cfg_bufs_reset(bufs, ospname);
        lustre_cfg_bufs_set_string(bufs, 1,
index 575d78b..542f761 100644 (file)
@@ -218,7 +218,7 @@ int walk_block_dqentry(const struct lu_env *env, struct osd_object *obj,
                       int type, uint blk, uint index,
                       struct osd_it_quota *it)
 {
-       dqbuf_t                          buf = getdqbuf();
+       dqbuf_t                          buf;
        loff_t                           ret = 0;
        struct lustre_disk_dqdbheader   *dqhead;
        int                              i, dqblk_sz;
@@ -232,6 +232,7 @@ int walk_block_dqentry(const struct lu_env *env, struct osd_object *obj,
                        RETURN(1);
        }
 
+       buf = getdqbuf();
        dqhead = (struct lustre_disk_dqdbheader *)buf;
        dqblk_sz = sizeof(struct lustre_disk_dqblk_v2);
        if (!buf)
index bb1c0b6..eefd0ea 100644 (file)
@@ -3111,6 +3111,7 @@ static int rmtacl_notify(int ops)
                 }
 
                 rc = ioctl(fd, LL_IOC_RMTACL, ops);
+               close(fd);
                 if (rc < 0) {
                         rc = -errno;
                         llapi_error(LLAPI_MSG_ERROR, rc, "ioctl %d\n", fd);
@@ -3122,8 +3123,6 @@ static int rmtacl_notify(int ops)
 
 out:
         endmntent(fp);
-       if (fd >= 0)
-               close(fd);
        return ((rc != 0) ? rc : found);
 }