X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=device.c;h=3f83cb4700f99ee4bc608ae5990cc63477ee618c;hp=e206a765669101d19f473fa8cdb927709df0e2a8;hb=a323f3adf275954727f32895eea37bfcf0aa9fb7;hpb=5f739f10e9d7af0eb412102356434f905ed8f467 diff --git a/device.c b/device.c index e206a76..3f83cb4 100644 --- a/device.c +++ b/device.c @@ -261,6 +261,15 @@ void device_add_user(struct device_user *dep, struct device *dev) } } +static void +__device_free_unused(struct device *dev) +{ + if (!list_empty(&dev->users)) + return; + + device_free(dev); +} + void device_remove_user(struct device_user *dep) { struct device *dev = dep->dev; @@ -269,22 +278,8 @@ void device_remove_user(struct device_user *dep) device_release(dep); list_del(&dep->list); - - if (list_empty(&dev->users)) { - /* all references have gone away, remove this device */ - device_free(dev); - } - dep->dev = NULL; -} - -static void -__device_free_unused(struct device *dev) -{ - if (!list_empty(&dev->users)) - return; - - device_free(dev); + __device_free_unused(dev); } void