From: Sebastien Buisson Date: Wed, 2 Oct 2013 15:09:35 +0000 (+0200) Subject: LU-4049 build: fix 'NULL pointer dereference' errors X-Git-Tag: 2.5.52~20 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a7a93b5a181c6d9eb9c481933e247439cdc5cb83 LU-4049 build: fix 'NULL pointer dereference' errors 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 Change-Id: I1db4e80fd2c048cc20459e8da4cb61a97b3171cb Reviewed-on: http://review.whamcloud.com/7827 Reviewed-by: John L. Hammond Tested-by: Jenkins Reviewed-by: jacques-Charles Lafoucriere Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index de7a5cb..676e0f0 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -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(¶m->fsp_env, param->fsp_it); lu_env_fini(¶m->fsp_env); diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 5d74c88..857320d 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -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); diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index bc1e489..39e63f4 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -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);