Skip to content
Snippets Groups Projects
Commit bba6d72d authored by Guido Günther's avatar Guido Günther
Browse files

New patch 0008-Fix-leaks-in-udev-device-add-remove.patch

Fix leaks in udev device add/remove.

Closes: #582965
Thanks: Nigel Jones for forwarding this
parent e4f08698
No related branches found
No related tags found
No related merge requests found
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Mon, 7 Jun 2010 18:20:04 +0200
Subject: [PATCH] Fix leaks in udev device add/remove
Patch pulled from upstream git.
Closes: #582965
Thanks: Nigel Jones for forwarding
---
src/node_device/node_device_udev.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index bcfe991..1cf7fa7 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1195,6 +1195,8 @@ static int udevRemoveOneDevice(struct udev_device *device)
}
nodeDeviceUnlock(driverState);
+ udev_device_unref(device);
+
return ret;
}
@@ -1281,13 +1283,14 @@ static int udevAddOneDevice(struct udev_device *device)
goto out;
}
+ /* If this is a device change, the old definition will be freed
+ * and the current definition will take its place. */
nodeDeviceLock(driverState);
dev = virNodeDeviceAssignDef(&driverState->devs, def);
nodeDeviceUnlock(driverState);
if (dev == NULL) {
VIR_ERROR("Failed to create device for '%s'", def->name);
- virNodeDeviceDefFree(def);
goto out;
}
@@ -1296,6 +1299,12 @@ static int udevAddOneDevice(struct udev_device *device)
ret = 0;
out:
+ if (ret != 0) {
+ virNodeDeviceDefFree(def);
+ }
+
+ udev_device_unref(device);
+
return ret;
}
@@ -1315,7 +1324,6 @@ static int udevProcessDeviceListEntry(struct udev *udev,
VIR_INFO("Failed to create node device for udev device '%s'",
name);
}
- udev_device_unref(device);
ret = 0;
}
--
......@@ -5,3 +5,4 @@
0005-Terminate-nc-on-EOF.patch
0006-Don-t-drop-caps-when-exec-ing-qemu.patch
0007-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
0008-Fix-leaks-in-udev-device-add-remove.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment