evdev: Always unref received udev devices
Whenever udev_monitor_receive_device() returns a non-null pointer, the device must be unref'd after use with udev_device_unref(). We previously missed some unref calls for non-evdev devices.
This commit is contained in:
parent
0822bb347d
commit
6a93223283
|
@ -76,10 +76,11 @@ static void HotplugThreadFunc()
|
||||||
if (ret < 1 || !FD_ISSET(monitor_fd, &fds))
|
if (ret < 1 || !FD_ISSET(monitor_fd, &fds))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
udev_device* dev = udev_monitor_receive_device(monitor);
|
std::unique_ptr<udev_device, decltype(&udev_device_unref)> dev{
|
||||||
|
udev_monitor_receive_device(monitor), udev_device_unref};
|
||||||
|
|
||||||
const char* action = udev_device_get_action(dev);
|
const char* action = udev_device_get_action(dev.get());
|
||||||
const char* devnode = udev_device_get_devnode(dev);
|
const char* devnode = udev_device_get_devnode(dev.get());
|
||||||
if (!devnode)
|
if (!devnode)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -107,7 +108,6 @@ static void HotplugThreadFunc()
|
||||||
s_devnode_name_map.insert(std::pair<std::string, std::string>(devnode, name));
|
s_devnode_name_map.insert(std::pair<std::string, std::string>(devnode, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
udev_device_unref(dev);
|
|
||||||
}
|
}
|
||||||
NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread stopped");
|
NOTICE_LOG(SERIALINTERFACE, "evdev hotplug thread stopped");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue