summaryrefslogtreecommitdiff
path: root/src/linux
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-22 12:34:52 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-09-03 08:31:27 +0200
commitdda9bc21e51d0b379eb800f911856683816166eb (patch)
tree571836447702cdb76816b4e4519b84e7f36e42de /src/linux
parent984d88f9437c1e1a3e5397829051eedb6564270e (diff)
downloadupower-dda9bc21e51d0b379eb800f911856683816166eb.tar.gz
hidpp: fix fd leak
Upon unplugging the USB receiver, the file descriptor of /dev/hidrawX is not closed. With commit "HID: hidraw: correctly deallocate memory on device disconnect"[1] (queued for 3.12), this missing close() causes a /dev/hidrawX devuce to persist until UPower is restarted. On earlier kernels, never remove your USB receiver or you will experience random errors resulting from data structures corruption[2] (which occurs because UPower tries to poll() or read() an hidraw device while the kernel has already released the memory for it). Not UPowers fault, but UPower makes this bug more likely since it runs as daemon. [1]: http://lkml.org/lkml/2013/7/22/248 [2]: http://lkml.org/lkml/2013/8/6/457 Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Diffstat (limited to 'src/linux')
-rw-r--r--src/linux/hidpp-device.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index c0a8dc8..4e47d88 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -990,6 +990,9 @@ hidpp_device_finalize (GObject *object)
g_free (device->priv->model);
g_free (device->priv->serial);
+ if (device->priv->fd > 0)
+ close (device->priv->fd);
+
G_OBJECT_CLASS (hidpp_device_parent_class)->finalize (object);
}