[ovs-dev] [memory fixes 5/6] netdev-linux: Fix pairing of rtnetlink register and unregister calls.
Ben Pfaff
blp at nicira.com
Mon Dec 13 21:10:50 UTC 2010
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.
---
lib/netdev-linux.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index ed97eb3..1efbfd8 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);
--
1.7.1
More information about the dev
mailing list