In ofd_getattr(), dt_version_get() could be called on a non-existant
object, leading to a NULL pointer for its inode.
It should try to call dt_version_get() only if attr_get returns
success; otherwise it will crash.
Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Signed-off-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Change-Id: I450fb78b85ea86d813ccad4de2f14f5bd4fca645
Reviewed-on: http://review.whamcloud.com/7124
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
struct ofd_device *ofd = ofd_exp(exp);
struct ofd_thread_info *info;
struct ofd_object *fo;
struct ofd_device *ofd = ofd_exp(exp);
struct ofd_thread_info *info;
struct ofd_object *fo;
fo = ofd_object_find(env, ofd, &info->fti_fid);
if (IS_ERR(fo))
GOTO(out, rc = PTR_ERR(fo));
fo = ofd_object_find(env, ofd, &info->fti_fid);
if (IS_ERR(fo))
GOTO(out, rc = PTR_ERR(fo));
+ if (!ofd_object_exists(fo))
+ GOTO(out_put, rc = -ENOENT);
+
LASSERT(fo != NULL);
rc = ofd_attr_get(env, fo, &info->fti_attr);
oinfo->oi_oa->o_valid = OBD_MD_FLID;
LASSERT(fo != NULL);
rc = ofd_attr_get(env, fo, &info->fti_attr);
oinfo->oi_oa->o_valid = OBD_MD_FLID;
+ if (rc == 0) {
+ __u64 curr_version;
+
obdo_from_la(oinfo->oi_oa, &info->fti_attr,
OFD_VALID_FLAGS | LA_UID | LA_GID);
obdo_from_la(oinfo->oi_oa, &info->fti_attr,
OFD_VALID_FLAGS | LA_UID | LA_GID);
- /* Store object version in reply */
- curr_version = dt_version_get(env, ofd_object_child(fo));
- if ((__s64)curr_version != -EOPNOTSUPP) {
- oinfo->oi_oa->o_valid |= OBD_MD_FLDATAVERSION;
- oinfo->oi_oa->o_data_version = curr_version;
+ /* Store object version in reply */
+ curr_version = dt_version_get(env, ofd_object_child(fo));
+ if ((__s64)curr_version != -EOPNOTSUPP) {
+ oinfo->oi_oa->o_valid |= OBD_MD_FLDATAVERSION;
+ oinfo->oi_oa->o_data_version = curr_version;
+ }
ofd_object_put(env, fo);
out:
RETURN(rc);
ofd_object_put(env, fo);
out:
RETURN(rc);