Whamcloud - gitweb
LU-17773 lov: avoid partly outside array bounds build error
authorBobi Jam <bobijam@whamcloud.com>
Sat, 1 Jun 2024 18:29:57 +0000 (11:29 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 6 Jun 2024 08:18:41 +0000 (08:18 +0000)
Avoid "array subscript 'struct lov_stripe_md_entry[0]’ is partly
outside array bounds of ‘struct lov_stripe_md_entry[0]’ error.
Otherwise an lsme holder will be allocated for invalid lmm magic.

Lustre-change: https://review.whamcloud.com/54944
Lustre-commit: TBD (from 2859950cc91df34ddaf0a45f5f37fa13faf99a5d)

Fixes: 902fe290 ("LU-17261 lov: ignore broken components")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I5a403a0d230d2129e372fd8a22f58901cd0c1b68
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54868
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lov/lov_ea.c

index 4610c86..bca438d 100644 (file)
@@ -533,23 +533,8 @@ lsme_unpack_comp(struct lov_obd *lov, struct lov_mds_md *lmm,
        unsigned int magic;
 
        magic = le32_to_cpu(lmm->lmm_magic);
-       if (!lov_supported_comp_magic(magic)) {
-               struct lov_stripe_md_entry *lsme;
-               size_t lsme_sz = offsetof(typeof(*lsme), lsme_oinfo[0]);
-               struct lov_stripe_md_entry lsme_init = {
-                       .lsme_pattern = le32_to_cpu(lmm->lmm_pattern),
-                       .lsme_magic = magic,
-               };
-
-               /* allocate a lsme holder for invalid magic lmm */
-               OBD_ALLOC_LARGE(lsme, lsme_sz);
-               if (!lsme)
-                       return ERR_PTR(-ENOMEM);
-
-               memcpy(lsme, &lsme_init, lsme_sz);
-
-               return lsme;
-       }
+       if (!lov_supported_comp_magic(magic))
+               RETURN(ERR_PTR(-EINVAL));
 
        if (magic != LOV_MAGIC_FOREIGN &&
            le16_to_cpu(lmm->lmm_stripe_count) == 0 &&