Module Name:    src
Committed By:   pgoyette
Date:           Wed Jun  3 11:43:16 UTC 2009

Modified Files:
        src/sys/dev/sysmon: sysmon_envsys.c

Log Message:
Don't allocate the private list-threading structure unless we're going
to use it.  Otherwise we end up leaking little bits of memory for each
sensor that is not monitored at time of initial registration.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/dev/sysmon/sysmon_envsys.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.85 src/sys/dev/sysmon/sysmon_envsys.c:1.86
--- src/sys/dev/sysmon/sysmon_envsys.c:1.85	Fri Aug 22 11:27:50 2008
+++ src/sys/dev/sysmon/sysmon_envsys.c	Wed Jun  3 11:43:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.85 2008/08/22 11:27:50 pgoyette Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.86 2009/06/03 11:43:15 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.85 2008/08/22 11:27:50 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.86 2009/06/03 11:43:15 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -640,6 +640,7 @@
 	prop_array_t array = NULL;
 	prop_dictionary_t dict, dict2;
 	envsys_data_t *edata = NULL;
+	sme_event_drv_t *this_evdrv;
 	int error = 0;
 
 	KASSERT(sme != NULL);
@@ -698,11 +699,13 @@
 		/*
 		 * Create all objects in sensor's dictionary.
 		 */
-		evdv = kmem_zalloc(sizeof(*evdv), KM_SLEEP);
-		evdv->evdrv = sme_add_sensor_dictionary(sme, array,
-				    	      		dict, edata);
-		if (evdv->evdrv)
+		this_evdrv = sme_add_sensor_dictionary(sme, array,
+						       dict, edata);
+		if (this_evdrv) {
+			evdv = kmem_zalloc(sizeof(*evdv), KM_SLEEP);
+			evdv->evdrv = this_evdrv;
 			SLIST_INSERT_HEAD(&sme_evdrv_list, evdv, evdrv_head);
+		}
 	}
 
 	/* 

Reply via email to