mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
netdev: Correctly maintain netdev refcounts even if errors occur.
If an error occured while opening a netdev it would decrement the refcount, even though it was never incremented. Depending on the timing this could result in either an error message or an assertion failure. This workaround simply always increments the refcount before openning a device. A more complete fix already exists in the netdev overhaul in the 'next' branch. NIC-59
This commit is contained in:
@@ -235,6 +235,7 @@ netdev_open(const char *name, int ethertype, struct netdev **netdevp)
|
||||
|
||||
netdev_obj = shash_find_data(&netdev_obj_shash, name);
|
||||
if (netdev_obj) {
|
||||
netdev_obj->ref_cnt++;
|
||||
error = netdev_obj->netdev_class->open(name, ethertype, &netdev);
|
||||
} else {
|
||||
/* Default to "system". */
|
||||
@@ -249,16 +250,14 @@ netdev_open(const char *name, int ethertype, struct netdev **netdevp)
|
||||
* closes its handle. */
|
||||
error = class->create(name, "system", &empty_args, false);
|
||||
if (!error) {
|
||||
error = class->open(name, ethertype, &netdev);
|
||||
netdev_obj = shash_find_data(&netdev_obj_shash, name);
|
||||
netdev_obj->ref_cnt++;
|
||||
error = class->open(name, ethertype, &netdev);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
netdev_obj->ref_cnt++;
|
||||
}
|
||||
|
||||
*netdevp = error ? NULL : netdev;
|
||||
return error;
|
||||
|
Reference in New Issue
Block a user