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

          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: