Whamcloud - gitweb
LU-7952 osp: Move strlen() call below LASSERT() 19/20919/5
authorArshad Hussain <arshad.hussain@seagate.com>
Tue, 21 Jun 2016 03:21:29 +0000 (08:51 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 23 Dec 2016 05:05:04 +0000 (05:05 +0000)
This patch moves the strlen() call below LASSERT(). This
avoids a case when parameter to strlen() is NULL and
dereferencing the NULL pointer would cause fault before
it reaches LASSERT().

Signed-off-by: Arshad Hussain <arshad.hussain@seagate.com>
Change-Id: Ie7a683751cf44d7dfad6de1a9024c5fb7a35c35d
Reviewed-on: https://review.whamcloud.com/20919
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
lustre/osp/osp_object.c

index 69795d5..cb1c252 100644 (file)
@@ -771,12 +771,14 @@ static int osp_declare_xattr_get(const struct lu_env *env, struct dt_object *dt,
        struct osp_object       *obj     = dt2osp_obj(dt);
        struct osp_device       *osp     = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_xattr_entry  *oxe;
        struct osp_object       *obj     = dt2osp_obj(dt);
        struct osp_device       *osp     = lu2osp_dev(dt->do_lu.lo_dev);
        struct osp_xattr_entry  *oxe;
-       __u16                    namelen = strlen(name);
+       __u16 namelen;
        int                      rc      = 0;
 
        LASSERT(buf != NULL);
        LASSERT(name != NULL);
 
        int                      rc      = 0;
 
        LASSERT(buf != NULL);
        LASSERT(name != NULL);
 
+       namelen = strlen(name);
+
        /* If only for xattr size, return directly. */
        if (unlikely(buf->lb_len == 0))
                return 0;
        /* If only for xattr size, return directly. */
        if (unlikely(buf->lb_len == 0))
                return 0;