From owner-svn-src-head@FreeBSD.ORG Sun Oct 24 15:41:24 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09208106566B; Sun, 24 Oct 2010 15:41:24 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EB47B8FC0A; Sun, 24 Oct 2010 15:41:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9OFfNrL032571; Sun, 24 Oct 2010 15:41:23 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9OFfN0N032567; Sun, 24 Oct 2010 15:41:23 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201010241541.o9OFfN0N032567@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Sun, 24 Oct 2010 15:41:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214274 - head/sbin/hastd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2010 15:41:24 -0000 Author: pjd Date: Sun Oct 24 15:41:23 2010 New Revision: 214274 URL: http://svn.freebsd.org/changeset/base/214274 Log: Plug memory leaks. Found with: valgrind MFC after: 3 days Modified: head/sbin/hastd/parse.y head/sbin/hastd/primary.c head/sbin/hastd/synch.h Modified: head/sbin/hastd/parse.y ============================================================================== --- head/sbin/hastd/parse.y Sun Oct 24 15:38:58 2010 (r214273) +++ head/sbin/hastd/parse.y Sun Oct 24 15:41:23 2010 (r214274) @@ -264,6 +264,7 @@ control_statement: CONTROL STR sizeof(depth0_control)) >= sizeof(depth0_control)) { pjdlog_error("control argument is too long."); + free($2); return (1); } break; @@ -274,12 +275,14 @@ control_statement: CONTROL STR sizeof(lconfig->hc_controladdr)) >= sizeof(lconfig->hc_controladdr)) { pjdlog_error("control argument is too long."); + free($2); return (1); } break; default: assert(!"control at wrong depth level"); } + free($2); } ; @@ -291,6 +294,7 @@ listen_statement: LISTEN STR sizeof(depth0_listen)) >= sizeof(depth0_listen)) { pjdlog_error("listen argument is too long."); + free($2); return (1); } break; @@ -301,12 +305,14 @@ listen_statement: LISTEN STR sizeof(lconfig->hc_listenaddr)) >= sizeof(lconfig->hc_listenaddr)) { pjdlog_error("listen argument is too long."); + free($2); return (1); } break; default: assert(!"listen at wrong depth level"); } + free($2); } ; @@ -357,6 +363,7 @@ exec_statement: EXEC STR if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >= sizeof(depth0_exec)) { pjdlog_error("Exec path is too long."); + free($2); return (1); } break; @@ -367,12 +374,14 @@ exec_statement: EXEC STR sizeof(curres->hr_exec)) >= sizeof(curres->hr_exec)) { pjdlog_error("Exec path is too long."); + free($2); return (1); } break; default: assert(!"exec at wrong depth level"); } + free($2); } ; @@ -386,6 +395,7 @@ node_start: STR { switch (isitme($1)) { case -1: + free($1); return (1); case 0: break; @@ -395,6 +405,7 @@ node_start: STR default: assert(!"invalid isitme() return value"); } + free($1); } ; @@ -482,14 +493,17 @@ resource_start: STR curres = calloc(1, sizeof(*curres)); if (curres == NULL) { pjdlog_error("Unable to allocate memory for resource."); + free($1); return (1); } if (strlcpy(curres->hr_name, $1, sizeof(curres->hr_name)) >= sizeof(curres->hr_name)) { pjdlog_error("Resource name is too long."); + free($1); return (1); } + free($1); curres->hr_role = HAST_ROLE_INIT; curres->hr_previous_role = HAST_ROLE_INIT; curres->hr_replication = -1; @@ -530,6 +544,7 @@ name_statement: NAME STR sizeof(depth1_provname)) >= sizeof(depth1_provname)) { pjdlog_error("name argument is too long."); + free($2); return (1); } break; @@ -541,12 +556,14 @@ name_statement: NAME STR sizeof(curres->hr_provname)) >= sizeof(curres->hr_provname)) { pjdlog_error("name argument is too long."); + free($2); return (1); } break; default: assert(!"name at wrong depth level"); } + free($2); } ; @@ -558,6 +575,7 @@ local_statement: LOCAL STR sizeof(depth1_localpath)) >= sizeof(depth1_localpath)) { pjdlog_error("local argument is too long."); + free($2); return (1); } break; @@ -569,12 +587,14 @@ local_statement: LOCAL STR sizeof(curres->hr_localpath)) >= sizeof(curres->hr_localpath)) { pjdlog_error("local argument is too long."); + free($2); return (1); } break; default: assert(!"local at wrong depth level"); } + free($2); } ; @@ -589,6 +609,7 @@ resource_node_start: STR if (curres != NULL) { switch (isitme($1)) { case -1: + free($1); return (1); case 0: break; @@ -599,6 +620,7 @@ resource_node_start: STR assert(!"invalid isitme() return value"); } } + free($1); } ; @@ -624,8 +646,10 @@ remote_statement: REMOTE STR sizeof(curres->hr_remoteaddr)) >= sizeof(curres->hr_remoteaddr)) { pjdlog_error("remote argument is too long."); + free($2); return (1); } } + free($2); } ; Modified: head/sbin/hastd/primary.c ============================================================================== --- head/sbin/hastd/primary.c Sun Oct 24 15:38:58 2010 (r214273) +++ head/sbin/hastd/primary.c Sun Oct 24 15:41:23 2010 (r214274) @@ -646,6 +646,7 @@ init_remote(struct hast_resource *res, s */ (void)hast_activemap_flush(res); } + nv_free(nvin); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; Modified: head/sbin/hastd/synch.h ============================================================================== --- head/sbin/hastd/synch.h Sun Oct 24 15:38:58 2010 (r214273) +++ head/sbin/hastd/synch.h Sun Oct 24 15:41:23 2010 (r214274) @@ -140,6 +140,8 @@ cv_init(pthread_cond_t *cv) assert(error == 0); error = pthread_cond_init(cv, &attr); assert(error == 0); + error = pthread_condattr_destroy(&attr); + assert(error == 0); } static __inline void cv_wait(pthread_cond_t *cv, pthread_mutex_t *lock)