From 59f7e9177af236086328a3af4fe3f89b278e2def Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 20 Jan 2010 16:24:11 +0000 Subject: 2010-01-20 Joel Sherrill 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. --- cpukit/libmisc/fsmount/fsmount.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cpukit/libmisc/fsmount') 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; } -- cgit v1.2.3