hal/hald/linux2 blockdev.c, 1.10, 1.11 classdev.c, 1.16,
1.17 coldplug.c, 1.11, 1.12 hotplug.c, 1.13, 1.14 physdev.c,
1.9, 1.10
David Zeuthen
david at freedesktop.org
Sun Feb 27 20:53:18 PST 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv22133/hald/linux2
Modified Files:
blockdev.c classdev.c coldplug.c hotplug.c physdev.c
Log Message:
2005-02-27 David Zeuthen <davidz at redhat.com>
More fun with valgrind :-)
* hald/linux2/classdev.c: Fix a bunch of leaks by calling
g_object_unref for HalDevice objects that goes away
* hald/linux2/physdev.c: Fix a bunch of leaks by calling
g_object_unref for HalDevice objects that goes away
* hald/linux2/hotplug.c (hotplug_event_begin_sysfs): Don't
leak parent_path
* hald/linux2/coldplug.c (free_hash_sys_to_class_in_dev): New
function; to free values of the sysfs_to_class_in_devices_map
hashtable
(coldplug_synthesize_events): Fix memory leaks
* hald/linux2/blockdev.c: Fix a bunch of leaks by calling
g_object_unref for HalDevice objects that goes away
* hald/property.c (hal_property_set_string): Don't leak old value
* hald/hald_dbus.c (sender_has_privileges): Fixup error handling
(device_property_atomic_update_end): Fix memory leak
* hald/hald.h: Add HALD_MEMLEAK_DBG but uncomment it by default
* hald/hald.c (my_shutdown): New function, defined only if
HALD_MEMLEAK_DBG is set; should prolly be invoked by handler
registered with atexit(3); some day in the future
(osspec_probe_done): Add appropriate timeout if HALD_MEMLEAK_DBG
is et
* hald/device.c (hal_device_finalize, hal_device_new): Recognize
the HALD_MEMLEAK_DBG define and maintain dbg_hal_device_object_delta
accordingly.
(hal_device_set_udi): Don't leak old udi
* hald/valgrind-hald.sh: New file - useful for finding memory
leaks
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- blockdev.c 25 Feb 2005 22:01:14 -0000 1.10
+++ blockdev.c 28 Feb 2005 04:53:15 -0000 1.11
@@ -148,6 +148,7 @@
if (!hal_device_store_remove (hald_get_gdl (), d)) {
HAL_WARNING (("Error removing device"));
}
+ g_object_unref (d);
hotplug_event_end (end_token);
}
@@ -272,12 +273,14 @@
*/
if (timed_out || !(return_code == 0 || (!is_volume && return_code == 2))) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
goto out;
}
if (!blockdev_compute_udi (d)) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
goto out;
}
@@ -350,6 +353,7 @@
NULL, add_blockdev_probing_helper_done,
HAL_HELPER_TIMEOUT) == NULL) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
}
goto out;
@@ -377,6 +381,7 @@
NULL, add_blockdev_probing_helper_done,
HAL_HELPER_TIMEOUT) == NULL) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
}
@@ -413,6 +418,7 @@
NULL, add_blockdev_probing_helper_done,
HAL_HELPER_TIMEOUT) == NULL) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
}
@@ -473,7 +479,7 @@
if (!is_fakevolume && hal_device_property_get_bool (parent, "storage.no_partitions_hint")) {
HAL_INFO (("Ignoring blockdev since not a fakevolume and parent has "
"storage.no_partitions_hint==TRUE"));
- goto out;
+ goto error;
}
}
Index: classdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/classdev.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- classdev.c 24 Feb 2005 17:33:03 -0000 1.16
+++ classdev.c 28 Feb 2005 04:53:15 -0000 1.17
@@ -285,6 +285,7 @@
error:
if (d != NULL) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
d = NULL;
}
@@ -548,6 +549,8 @@
HAL_WARNING (("Error removing device"));
}
+ g_object_unref (d);
+
hotplug_event_end (end_token);
}
@@ -561,6 +564,7 @@
/* Compute UDI */
if (!handler->compute_udi (d)) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
goto out;
}
@@ -586,6 +590,7 @@
/* Discard device if probing reports failure */
if (return_code != 0) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
goto out;
}
@@ -640,6 +645,7 @@
(gpointer) handler, add_classdev_probing_helper_done,
HAL_HELPER_TIMEOUT) == NULL) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
}
goto out;
Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- coldplug.c 28 Feb 2005 01:16:47 -0000 1.11
+++ coldplug.c 28 Feb 2005 04:53:15 -0000 1.12
@@ -59,6 +59,17 @@
/* For debugging */
/*#define HAL_COLDPLUG_VERBOSE*/
+static void
+free_hash_sys_to_class_in_dev (gpointer key, gpointer value, gpointer user_data)
+{
+ GSList *i;
+ GSList *list = (GSList *) value;
+
+ for (i = list; i != NULL; i = g_slist_next (i))
+ g_free (i->data);
+ g_slist_free (list);
+}
+
/** This function serves one major purpose : build an ordered list of
* pairs (sysfs path, subsystem) to process when starting up:
* coldplugging. The ordering is arranged such that all bus-devices
@@ -180,8 +191,8 @@
}
g_dir_close (dir);
- /* build class map and class device map */
- sysfs_to_class_in_devices_map = g_hash_table_new (g_str_hash, g_str_equal);
+ /* build class map and class device map (values are free in separate foreach()) */
+ sysfs_to_class_in_devices_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_snprintf (path, HAL_PATH_MAX, "%s/class" , get_hal_sysfs_path ());
if ((dir = g_dir_open (path, 0, &err)) == NULL) {
HAL_ERROR (("Unable to open %/class: %s", get_hal_sysfs_path (), err->message));
@@ -211,10 +222,8 @@
GSList *classdev_strings;
g_snprintf (path2, HAL_PATH_MAX, "%s/class/%s/%s", get_hal_sysfs_path (), f, f1);
- if (target) {
- normalized_target = hal_util_get_normalized_path (path2, target);
- g_free (target);
- }
+ normalized_target = hal_util_get_normalized_path (path2, target);
+ g_free (target);
classdev_strings = g_hash_table_lookup (sysfs_to_class_in_devices_map,
normalized_target);
@@ -257,6 +266,8 @@
g_dir_close (dir);
g_hash_table_destroy (sysfs_to_bus_map);
+ /* free keys and values in this complex hash */
+ g_hash_table_foreach (sysfs_to_class_in_devices_map, free_hash_sys_to_class_in_dev, NULL);
g_hash_table_destroy (sysfs_to_class_in_devices_map);
/* we are guaranteed, per construction, that the len of this list is even */
Index: hotplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/hotplug.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- hotplug.c 25 Feb 2005 03:32:48 -0000 1.13
+++ hotplug.c 28 Feb 2005 04:53:15 -0000 1.14
@@ -259,6 +259,8 @@
is_partition,
(void *) hotplug_event);
}
+
+ g_free (parent_path);
} else {
/* just ignore this hotplug event */
hotplug_event_end ((void *) hotplug_event);
Index: physdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/physdev.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- physdev.c 24 Feb 2005 17:33:03 -0000 1.9
+++ physdev.c 28 Feb 2005 04:53:15 -0000 1.10
@@ -852,6 +852,7 @@
if (!hal_device_store_remove (hald_get_gdl (), d)) {
HAL_WARNING (("Error removing device"));
}
+ g_object_unref (d);
hotplug_event_end (end_token);
}
@@ -890,6 +891,7 @@
/* Compute UDI */
if (!handler->compute_udi (d)) {
hal_device_store_remove (hald_get_tdl (), d);
+ g_object_unref (d);
hotplug_event_end (end_token);
goto out;
}
More information about the hal-commit
mailing list