struct lov_ost_data_v1 *objs;
__u32 magic;
int i, rc, lmm_size;
+ int cplen = 0;
ENTRY;
LASSERT(lo);
objs = &lmm->lmm_objects[0];
} else {
struct lov_mds_md_v3 *v3 = (struct lov_mds_md_v3 *) lmm;
- strncpy(v3->lmm_pool_name, lo->ldo_pool, LOV_MAXPOOLNAME);
+ cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool,
+ sizeof(v3->lmm_pool_name));
+ if (cplen >= sizeof(v3->lmm_pool_name))
+ RETURN(-E2BIG);
objs = &v3->lmm_objects[0];
}
struct dt_object *next = dt_object_child(dt);
struct lov_user_md_v3 *v3;
int rc;
+ int cplen = 0;
ENTRY;
LASSERT(S_ISDIR(dt->do_lu.lo_header->loh_attr));
v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size);
v3->lmm_stripe_count = cpu_to_le16(lo->ldo_def_stripenr);
v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset);
- if (lo->ldo_pool)
- strncpy(v3->lmm_pool_name, lo->ldo_pool, LOV_MAXPOOLNAME);
+ if (lo->ldo_pool) {
+ cplen = strlcpy(v3->lmm_pool_name, lo->ldo_pool,
+ sizeof(v3->lmm_pool_name));
+ if (cplen >= sizeof(v3->lmm_pool_name)) {
+ OBD_FREE_PTR(v3);
+ RETURN(-E2BIG);
+ }
+ }
info->lti_buf.lb_buf = v3;
info->lti_buf.lb_len = sizeof(*v3);
struct lod_device *md = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
struct lu_object *o, *n;
struct lu_device *nd;
- int i, idx, rc = 0;
+ struct dt_object **stripe;
+ int stripe_len;
+ int i, idx, rc = 0;
ENTRY;
LASSERT(lo);
LASSERT(lo->ldo_stripenr > 0);
LASSERT(lo->ldo_stripe_size > 0);
- i = sizeof(struct dt_object *) * lo->ldo_stripenr;
- OBD_ALLOC(lo->ldo_stripe, i);
- if (lo->ldo_stripe == NULL)
- GOTO(out, rc = -ENOMEM);
- lo->ldo_stripes_allocated = lo->ldo_stripenr;
+ stripe_len = lo->ldo_stripenr;
+ OBD_ALLOC(stripe, sizeof(stripe[0]) * stripe_len);
+ if (stripe == NULL)
+ RETURN(-ENOMEM);
for (i = 0; i < lo->ldo_stripenr; i++) {
info->lti_ostid.oi_id = le64_to_cpu(objs[i].l_object_id);
n = lu_object_locate(o->lo_header, nd->ld_type);
LASSERT(n);
- lo->ldo_stripe[i] = container_of(n, struct dt_object, do_lu);
+ stripe[i] = container_of(n, struct dt_object, do_lu);
}
out:
+ if (rc != 0) {
+ for (i = 0; i < stripe_len; i++)
+ if (stripe[i] != NULL)
+ lu_object_put(env, &stripe[i]->do_lu);
+
+ OBD_FREE(stripe, sizeof(stripe[0]) * stripe_len);
+ } else {
+ lo->ldo_stripe = stripe;
+ lo->ldo_stripes_allocated = stripe_len;
+ }
+
RETURN(rc);
}