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

Uninitialized variable use in fld_update_from_controller

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      In looks like we can use index variable without initialization in fld_update_from_controller:

              __u32                     index;
      ...
              rc = fld_name_to_index(fld->lsf_name, &index);
              if (rc < 0)
                      RETURN(rc);
      
              /* No need update fldb for MDT0 */
              if (index == 0)
                      RETURN(0);
      

      Now if we look into fld_name_to_index() it looks ok:

      int fld_name_to_index(const char *name, __u32 *index)
      {
              char *dash;
              int rc;
              ENTRY;
      
              CDEBUG(D_INFO, "get index from %s\n", name);
              dash = strrchr(name, '-');
              if (dash == NULL)
                      RETURN(-EINVAL);
              dash++;
              rc = target_name2index(dash, index, NULL);
              RETURN(rc);
      }
      

      As in we return negative value to caller if the index is not updated.

      But if we actually look inside target_name2index, we can see:

              if (strncmp(dash, "MDT", 3) == 0)
                      rc = LDD_F_SV_TYPE_MDT;
              else if (strncmp(dash, "OST", 3) == 0)
                      rc = LDD_F_SV_TYPE_OST;
              else
                      return -EINVAL;
      
              dash += 3;
      
              if (strncmp(dash, "all", 3) == 0) {
                      if (endptr != NULL)
                              *endptr = dash + 3;
                      return rc | LDD_F_SV_ALL;
              }
      

      so if we have 'all' literal after the dash - the index is not updated and we don't return an error.

      This needs to be handled one way or another.

      Attachments

        Activity

          People

            wc-triage WC Triage
            green Oleg Drokin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: