]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/lustre/lustre/lov/lov_obd.c
staging/lustre/lov: don't crash accessing LOV object with FID{0, 0}
[karo-tx-linux.git] / drivers / staging / lustre / lustre / lov / lov_obd.c
index b2ed52f20afbf9cadf9e563164a094bdf7d94654..02781576637edd64657486d548fc8364a75550d5 100644 (file)
@@ -1011,9 +1011,13 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
        }
 
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               if (lsm->lsm_oinfo[i]->loi_ost_idx == ost_idx) {
-                       if (ostid_id(&lsm->lsm_oinfo[i]->loi_oi) !=
-                                       ostid_id(&src_oa->o_oi)) {
+               struct lov_oinfo *loi = lsm->lsm_oinfo[i];
+
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
+               if (loi->loi_ost_idx == ost_idx) {
+                       if (ostid_id(&loi->loi_oi) != ostid_id(&src_oa->o_oi)) {
                                rc = -EINVAL;
                                goto out;
                        }
@@ -1305,10 +1309,14 @@ static int lov_find_cbdata(struct obd_export *exp,
                struct lov_stripe_md submd;
                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
 
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (!lov->lov_tgts[loi->loi_ost_idx]) {
-                       CDEBUG(D_HA, "lov idx %d NULL \n", loi->loi_ost_idx);
+                       CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx);
                        continue;
                }
+
                submd.lsm_oi = loi->loi_oi;
                submd.lsm_stripe_count = 0;
                rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
@@ -1616,8 +1624,12 @@ static u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap,
 
        /* Find out stripe_no from ost_index saved in the fe_device */
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               if (lsm->lsm_oinfo[i]->loi_ost_idx ==
-                                       fiemap->fm_extents[0].fe_device) {
+               struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
+
+               if (lov_oinfo_is_dummy(oinfo))
+                       continue;
+
+               if (oinfo->loi_ost_idx == fiemap->fm_extents[0].fe_device) {
                        stripe_no = i;
                        break;
                }
@@ -1795,6 +1807,11 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
                                           &lun_start, &obd_object_end)) == 0)
                        continue;
 
+               if (lov_oinfo_is_dummy(lsm->lsm_oinfo[cur_stripe])) {
+                       rc = -EIO;
+                       goto out;
+               }
+
                /* If this is a continuation FIEMAP call and we are on
                 * starting stripe then lun_start needs to be set to
                 * fm_end_offset */
@@ -1985,6 +2002,9 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp,
                 * be NULL and won't match the lock's export. */
                for (i = 0; i < lsm->lsm_stripe_count; i++) {
                        loi = lsm->lsm_oinfo[i];
+                       if (lov_oinfo_is_dummy(loi))
+                               continue;
+
                        if (!lov->lov_tgts[loi->loi_ost_idx])
                                continue;
                        if (lov->lov_tgts[loi->loi_ost_idx]->ltd_exp ==