1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix libdevmapper-event memory leaks

This commit is contained in:
Milan Broz 2007-04-19 19:10:19 +00:00
parent 662e0238f0
commit 0329281b49
2 changed files with 23 additions and 0 deletions

View File

@ -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+]

View 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;