]> sourceware.org Git - dm.git/commitdiff
Fix libdevmapper-event memory leaks
authorMilan Broz <mbroz@redhat.com>
Thu, 19 Apr 2007 19:10:19 +0000 (19:10 +0000)
committerMilan Broz <mbroz@redhat.com>
Thu, 19 Apr 2007 19:10:19 +0000 (19:10 +0000)
WHATS_NEW
dmeventd/libdevmapper-event.c

index 87e3ed507eef71c8db49f2834a05c0e673f3e2f6..67e004f5ec7ac711265bcc6f1aa516958cd3b106 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 1.02.19 -
 ====================================
+  Fix libdevmapper-event memory leaks
   Remove unnecessary memset() return value checks.
   Fix a few leaks in reporting error paths. [1.02.15+]
 
index d2f8ac503f71e86e4469a816982c0c005a74209f..fa59bd4896336b348c50477f6d7d586707c0104b 100644 (file)
@@ -359,10 +359,17 @@ static int _daemon_talk(struct dm_event_fifos *fifos,
         */
        if (!_daemon_write(fifos, msg)) {
                stack;
+               dm_free(msg->data);
+               msg->data = 0;
                return -EIO;
        }
 
        do {
+
+               if (msg->data)
+                       dm_free(msg->data);
+               msg->data = 0;
+
                if (!_daemon_read(fifos, msg)) {
                        stack;
                        return -EIO;
@@ -548,6 +555,11 @@ static int _do_event(int cmd, struct dm_event_daemon_message *msg,
        }
 
        ret = _daemon_talk(&fifos, msg, DM_EVENT_CMD_HELLO, 0, 0, 0, 0);
+
+       if (msg->data)
+               dm_free(msg->data);
+       msg->data = 0;
+
        if (!ret)
                ret = _daemon_talk(&fifos, msg, cmd, dso_name, dev_name, evmask, timeout);
 
@@ -714,6 +726,12 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
 
        dm_event_handler_set_dso(dmevh, reply_dso);
        dm_event_handler_set_event_mask(dmevh, reply_mask);
+
+       if (reply_dso)
+               dm_free(reply_dso);
+       if (reply_uuid)
+               dm_free(reply_uuid);
+
        dmevh->dev_name = dm_strdup(dm_task_get_name(dmt));
        if (!dmevh->dev_name) {
                ret = -ENOMEM;
@@ -736,6 +754,10 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
  fail:
        if (msg.data)
                dm_free(msg.data);
+       if (reply_dso)
+               dm_free(reply_dso);
+       if (reply_uuid)
+               dm_free(reply_uuid);
        _dm_event_handler_clear_dev_info(dmevh);
        dm_task_destroy(dmt);
        return ret;
This page took 0.054585 seconds and 5 git commands to generate.