ubik: Don't leak memory if mutex init fails
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 19 Feb 2013 16:15:29 +0000 (16:15 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Sun, 24 Feb 2013 19:09:40 +0000 (11:09 -0800)
If we can't initialise the ubik_client mutex, don't leak the
structure when returning an error.

Caught by clang-analyzer

Change-Id: Ib36d2ddf585a31b628e56dce1f33ee859fc835bc
Reviewed-on: http://gerrit.openafs.org/9182
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/ubik/ubikclient.c

index d8747cb..f39ba1e 100644 (file)
@@ -228,6 +228,7 @@ ubik_ClientInit(struct rx_connection **serverconns,
     memset((void *)tc, 0, sizeof(*tc));
 #ifdef AFS_PTHREAD_ENV
     if (pthread_mutex_init(&(tc->cm), (const pthread_mutexattr_t *)0)) {
+       free(tc);
        return UMUTEXINIT;
     }
 #endif