summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/fsmount
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-20 16:24:11 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-01-20 16:24:11 +0000
commit59f7e9177af236086328a3af4fe3f89b278e2def (patch)
treecf6351bfba2000dd651771da98961e3814db8ebb /cpukit/libmisc/fsmount
parent2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-59f7e9177af236086328a3af4fe3f89b278e2def.tar.bz2
2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 27 * libmisc/fsmount/fsmount.c: Ensure calloc() returns memory and then we do not have to check null when freeing it. Coverity noted it was used before being checked for NULL.
Diffstat (limited to 'cpukit/libmisc/fsmount')
-rw-r--r--cpukit/libmisc/fsmount/fsmount.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/cpukit/libmisc/fsmount/fsmount.c b/cpukit/libmisc/fsmount/fsmount.c
index 6e9ba263a7..2adfcb5d09 100644
--- a/cpukit/libmisc/fsmount/fsmount.c
+++ b/cpukit/libmisc/fsmount/fsmount.c
@@ -70,14 +70,20 @@ int rtems_fsmount_create_mount_point
* allocate temp memory to rebuild path name
*/
tok_buffer = calloc(strlen(mount_point)+1,sizeof(char));
+ if ( !tok_buffer )
+ return -1;
token = tok_buffer;
total_len = 0;
do {
/*
* scan through given string, one segment at a time
*/
- token_type = IMFS_get_token(mount_point+total_len,strlen(mount_point+total_len),
- token,&token_len);
+ token_type = IMFS_get_token(
+ mount_point+total_len,
+ strlen(mount_point+total_len),
+ token,
+ &token_len
+ );
total_len += token_len;
strncpy(tok_buffer,mount_point,total_len);
tok_buffer[total_len] = '\0';
@@ -100,11 +106,9 @@ int rtems_fsmount_create_mount_point
(token_type != IMFS_INVALID_TOKEN));
/*
- * return token buffer to heap
+ * return token buffer to heap. Verified to be non-NULL when calloc'ed.
*/
- if (tok_buffer != NULL) {
- free(tok_buffer);
- }
+ free(tok_buffer);
return rc;
}