Skip to content

Commit

Permalink
udev: Do not overwrite original device pointer
Browse files Browse the repository at this point in the history
Overwriting the original device pointer would unref an incorrect
instance during cleanup, resulting to a memory leak.

Change-Id: Ieac4a2de98eec329aa42dedce9601c44348ba4d9
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>

[mer] Always unref udev_device produced by udev_monitor_receive_device. Contributes to JB#34932
  • Loading branch information
Mikko Harju authored and monich committed Sep 25, 2017
1 parent 9d649d4 commit 312a519
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 312a519

Please sign in to comment.