netdev-linux: Fix fd leak on error path.
authorBen Pfaff <blp@nicira.com>
Fri, 26 Jul 2013 00:03:03 +0000 (17:03 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 2 Aug 2013 19:24:18 +0000 (12:24 -0700)
Found by inspection.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/netdev-linux.c

index 301a754..0baa40f 100644 (file)
@@ -672,19 +672,21 @@ netdev_linux_create_tap(const struct netdev_class *class OVS_UNUSED,
         VLOG_WARN("%s: creating tap device failed: %s", name,
                   ovs_strerror(errno));
         error = errno;
-        goto error_unref_notifier;
+        goto error_close;
     }
 
     /* Make non-blocking. */
     error = set_nonblocking(state->fd);
     if (error) {
-        goto error_unref_notifier;
+        goto error_close;
     }
 
     netdev_init(&netdev->up, name, &netdev_tap_class);
     *netdevp = &netdev->up;
     return 0;
 
+error_close:
+    close(state->fd);
 error_unref_notifier:
     cache_notifier_unref();
 error: