Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-5430

Function lmv_mds_md_size() can return -EINVAL which is never checked

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • Lustre 2.15.0
    • None
    • 3
    • 15120

    Description

      static inline int lmv_mds_md_size(int stripe_count, unsigned int lmm_magic)
      {
      	switch (lmm_magic) {
      	case LMV_MAGIC_V1:{
      		struct lmv_mds_md_v1 *lmm1;
      
      		return sizeof(*lmm1) + stripe_count *
      				       sizeof(lmm1->lmv_stripe_fids[0]);
      	}
      	default:
      		return -EINVAL;
      	}
      }
      

      It's not critical now because of magic is LMV_MAGIC_V1 always but can affect in the future.

      In few places the value checked for zero.

      lmm_size = lmv_mds_md_size(stripe_count, le32_to_cpu((*lmmp)->lmv_magic));
      if (lmm_size == 0)
      	RETURN(-EINVAL);
      

      So, probably it will be better return zero in case of wrong magic and return type change to size_t.

      Attachments

        Issue Links

          Activity

            People

              wc-triage WC Triage
              dmiter Dmitry Eremin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: