From: Ben Pfaff Date: Mon, 13 Dec 2010 21:07:48 +0000 (-0800) Subject: netdev-linux: Fix pairing of rtnetlink register and unregister calls. X-Git-Tag: v1.1.0~620 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d2bb2799e1b7cf2177140cf4ca8a60312c87625a;p=sliver-openvswitch.git 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. --- diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index ed97eb3c5..1efbfd88a 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -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);