2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev-linux: Fix pairing of rtnetlink register and unregister calls.

netdev_linux_create() called rtnetlink_notifier_register() for both system
and internal devices, but netdev_linux_destroy() only did the reverse
accounting for system devices.  This fixes the pairing.

This isn't really much of a bug, since it would only cause the notifier to
be active unnecessarily (not to be removed even though it was needed).  At
most it was a missed opportunity for optimization, but I don't think that
optimization would ever happen anyway.

Found with valgrind --leak-check=full --show-reachable=yes.
This commit is contained in:
Ben Pfaff
2010-12-13 13:07:48 -08:00
parent 83c19ab15a
commit d2bb2799e1

View File

@@ -598,20 +598,22 @@ static void
netdev_linux_destroy(struct netdev_dev *netdev_dev_)
{
struct netdev_dev_linux *netdev_dev = netdev_dev_linux_cast(netdev_dev_);
const char *type = netdev_dev_get_type(netdev_dev_);
const struct netdev_class *class = netdev_dev_get_class(netdev_dev_);
if (netdev_dev->tc && netdev_dev->tc->ops->tc_destroy) {
netdev_dev->tc->ops->tc_destroy(netdev_dev->tc);
}
if (!strcmp(type, "system")) {
if (class == &netdev_linux_class || class == &netdev_internal_class) {
cache_notifier_refcount--;
if (!cache_notifier_refcount) {
rtnetlink_notifier_unregister(&netdev_linux_cache_notifier);
}
} else if (!strcmp(type, "tap")) {
} else if (class == &netdev_tap_class) {
destroy_tap(netdev_dev);
} else {
NOT_REACHED();
}
free(netdev_dev);