netdev-vport: Fix segfault on bad vport configuration.
authorBen Pfaff <blp@nicira.com>
Fri, 19 Nov 2010 21:07:56 +0000 (13:07 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 19 Nov 2010 21:07:56 +0000 (13:07 -0800)
When a vport parse error occurs, the vport_class's parse_config function
doesn't necessarily store a valid pointer into the vport_info's 'config'
member, so netdev_vport_create() needs to supply a null pointer here to
avoiding passing a wild pointer to free().

lib/netdev-vport.c

index 7bc4d03..197e74b 100644 (file)
@@ -110,7 +110,7 @@ netdev_vport_parse_config(const struct netdev_class *netdev_class,
         info.devname = name;
         info.type = netdev_class->type;
         error = (c->parse_config)(&info, args);
-        *configp = info.config;
+        *configp = error ? NULL : info.config;
         return error;
     } else {
         if (!shash_is_empty(args)) {