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

bad NULL pointer check in cb_migrate_mdt_init()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • Lustre 2.8.0
    • Lustre 2.8.0
    • 3
    • 9223372036854775807

      At the end of cb_migrate_mdt_init(), after calling opendir() we should test *dirp rather than dirp:

      out:
              if (dirp != NULL) {
                      /* If the directory is being migration, we need
                       * close the directory after migration,
                       * so the old directory cache will be cleanup
                       * on the client side, and re-open to get the
                       * new directory handle */
                      *dirp = opendir(path);
      		if (dirp == NULL) {
                              ret = -errno;
                              llapi_error(LLAPI_MSG_ERROR, ret,
                                          "%s: Failed to open '%s'", __func__, path);
      			return ret;
                      }
              }
      
              if (parent == NULL)
                      closedir(dir);
      
              return ret;
      
      

      We also may leak dir on early return but the logic of this function is so convoluted that it's hard to tell.

            emoly.liu Emoly Liu
            jhammond John Hammond
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: