Codebase list libvirt / bba6d72
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 Guido Günther 13 years ago
2 changed file(s) with 64 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
1 Date: Mon, 7 Jun 2010 18:20:04 +0200
2 Subject: [PATCH] Fix leaks in udev device add/remove
3
4 Patch pulled from upstream git.
5
6 Closes: #582965
7 Thanks: Nigel Jones for forwarding
8 ---
9 src/node_device/node_device_udev.c | 12 ++++++++++--
10 1 files changed, 10 insertions(+), 2 deletions(-)
11
12 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
13 index bcfe991..1cf7fa7 100644
14 --- a/src/node_device/node_device_udev.c
15 +++ b/src/node_device/node_device_udev.c
16 @@ -1195,6 +1195,8 @@ static int udevRemoveOneDevice(struct udev_device *device)
17 }
18 nodeDeviceUnlock(driverState);
19
20 + udev_device_unref(device);
21 +
22 return ret;
23 }
24
25 @@ -1281,13 +1283,14 @@ static int udevAddOneDevice(struct udev_device *device)
26 goto out;
27 }
28
29 + /* If this is a device change, the old definition will be freed
30 + * and the current definition will take its place. */
31 nodeDeviceLock(driverState);
32 dev = virNodeDeviceAssignDef(&driverState->devs, def);
33 nodeDeviceUnlock(driverState);
34
35 if (dev == NULL) {
36 VIR_ERROR("Failed to create device for '%s'", def->name);
37 - virNodeDeviceDefFree(def);
38 goto out;
39 }
40
41 @@ -1296,6 +1299,12 @@ static int udevAddOneDevice(struct udev_device *device)
42 ret = 0;
43
44 out:
45 + if (ret != 0) {
46 + virNodeDeviceDefFree(def);
47 + }
48 +
49 + udev_device_unref(device);
50 +
51 return ret;
52 }
53
54 @@ -1315,7 +1324,6 @@ static int udevProcessDeviceListEntry(struct udev *udev,
55 VIR_INFO("Failed to create node device for udev device '%s'",
56 name);
57 }
58 - udev_device_unref(device);
59 ret = 0;
60 }
61
62 --
44 0005-Terminate-nc-on-EOF.patch
55 0006-Don-t-drop-caps-when-exec-ing-qemu.patch
66 0007-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
7 0008-Fix-leaks-in-udev-device-add-remove.patch