From 0b1f439cb294eb4c6e1fe2855b68534e683a165f Mon Sep 17 00:00:00 2001 From: Mikko Harju Date: Mon, 17 Aug 2015 16:02:57 +0300 Subject: udev: Do not overwrite original device pointer Overwriting the original device pointer would unref an incorrect instance during cleanup, resulting to a memory leak. Change-Id: Ieac4a2de98eec329aa42dedce9601c44348ba4d9 Reviewed-by: Robin Burchell --- src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp index 8fa82e2ad7..96fa058f78 100644 --- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp +++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp @@ -185,11 +185,11 @@ void QDeviceDiscoveryUDev::handleUDevNotification() // if we cannot determine a type, walk up the device tree if (!checkDeviceType(dev)) { // does not increase the refcount - dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0); - if (!dev) + struct udev_device *parent_dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0); + if (!parent_dev) goto cleanup; - if (!checkDeviceType(dev)) + if (!checkDeviceType(parent_dev)) goto cleanup; } -- cgit v1.2.3