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

potential memory leak in gssd_get_krb5_machine_cred_list

Details

    • Bug
    • Resolution: Fixed
    • Minor
    • Lustre 2.8.0
    • None
    • None
    • Ubuntu 15.04
    • 1
    • 9223372036854775807

    Description

      static analysis by cppcheck has found a potential memory leak in gssd_get_krb5_machine_cred_list():

      [lustre/utils/gss/krb5_util.c:918]: (error) Common realloc mistake: 'l' nulled but not freed upon failure

      listsize += listinc;
      l = (char **)
      realloc(l, listsize * sizeof(char *));
      if (l == NULL)

      { retval = ENOMEM; goto out; }

      The semantics of realloc are to return NULL when the allocation fails, but won't free the original allocation:

      "The realloc() function returns a pointer to the newly allocated memory,
      which is suitably aligned for any built-in type and may be different
      from ptr, or NULL if the request fails. If size was equal to 0, either
      NULL or a pointer suitable to be passed to free() is returned. If
      realloc() fails, the original block is left untouched; it is not freed
      or moved."

      so, one needs to do something like:

      tmp = (char **)realloc(l, listsize * sizeof(char *));
      if (tmp)
      l = tmp;
      else {
      retval = ENOMEM;
      goto out;
      }

      Attachments

        Activity

          [LU-6541] potential memory leak in gssd_get_krb5_machine_cred_list
          pjones Peter Jones added a comment -

          Landed for 2.8

          pjones Peter Jones added a comment - Landed for 2.8

          Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/14814/
          Subject: LU-6541 utils: fix potential memory leaks with realloc()
          Project: fs/lustre-release
          Branch: master
          Current Patch Set:
          Commit: 55f2a237320f23cb59df23518f5a72698d4f251c

          gerrit Gerrit Updater added a comment - Oleg Drokin (oleg.drokin@intel.com) merged in patch http://review.whamcloud.com/14814/ Subject: LU-6541 utils: fix potential memory leaks with realloc() Project: fs/lustre-release Branch: master Current Patch Set: Commit: 55f2a237320f23cb59df23518f5a72698d4f251c

          People

            dmiter Dmitry Eremin (Inactive)
            colinianking Colin Ian King
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: