Whamcloud - gitweb
LU-4049 build: fix 'NULL pointer dereference' errors 27/7827/6
authorSebastien Buisson <sebastien.buisson@bull.net>
Wed, 2 Oct 2013 15:09:35 +0000 (17:09 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 2 Dec 2013 12:49:38 +0000 (12:49 +0000)
Fix 'NULL pointer dereference' defects found by Coverity version
6.6.1:
Dereference after null check (FORWARD_NULL)
For instance, Passing null pointer to a function which dereferences
it.
Dereference before null check (REVERSE_INULL)
Null-checking variable suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.
Dereference null return value (NULL_RETURNS)

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: I1db4e80fd2c048cc20459e8da4cb61a97b3171cb
Reviewed-on: http://review.whamcloud.com/7827
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fid/lproc_fid.c
lustre/lod/lod_lov.c
lustre/lov/lov_pack.c

index de7a5cb..676e0f0 100644 (file)
@@ -420,7 +420,6 @@ static int fldb_seq_release(struct inode *inode, struct file *file)
        iops = &obj->do_index_ops->dio_it;
 
        LASSERT(iops != NULL);
-       LASSERT(obj != NULL);
        LASSERT(param->fsp_it != NULL);
        iops->fini(&param->fsp_env, param->fsp_it);
        lu_env_fini(&param->fsp_env);
index 5d74c88..857320d 100644 (file)
@@ -695,7 +695,7 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo,
                           struct lov_ost_data_v1 *objs)
 {
        struct lod_thread_info  *info = lod_env_info(env);
-       struct lod_device       *md = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
+       struct lod_device       *md;
        struct lu_object        *o, *n;
        struct lu_device        *nd;
        struct dt_object       **stripe;
@@ -704,6 +704,7 @@ int lod_initialize_objects(const struct lu_env *env, struct lod_object *lo,
        ENTRY;
 
        LASSERT(lo != NULL);
+       md = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
        LASSERT(lo->ldo_stripe == NULL);
        LASSERT(lo->ldo_stripenr > 0);
        LASSERT(lo->ldo_stripe_size > 0);
index bc1e489..39e63f4 100644 (file)
@@ -372,9 +372,11 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
                 if (rc)
                         RETURN(rc);
                 magic = le32_to_cpu(lmm->lmm_magic);
+               pattern = le32_to_cpu(lmm->lmm_pattern);
         } else {
                 magic = LOV_MAGIC;
                 stripe_count = lov_get_stripecnt(lov, magic, 0);
+               pattern = LOV_PATTERN_RAID0;
         }
 
         /* If we aren't passed an lsmp struct, we just want the size */
@@ -389,7 +391,6 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
                 RETURN(0);
         }
 
-       pattern = le32_to_cpu(lmm->lmm_pattern);
         lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
         if (lsm_size < 0)
                 RETURN(lsm_size);