summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-22 12:34:52 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-08-22 22:59:27 +0200
commitab75c60b1e678518983be1558c9a4de2008871cb (patch)
treec20c4d0c2ce71722007bc7826d8d6d86b9986bb3
parent909c594d079410c766033b8eee20647b945155c2 (diff)
downloadupower-ab75c60b1e678518983be1558c9a4de2008871cb.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>
-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);
}