]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Unregister the children when unregistering the parent
authorPiotr Jaroszyński <p.jaroszynski@gmail.com>
Wed, 14 Jul 2010 20:25:55 +0000 (22:25 +0200)
committerMichael Brown <mcb30@ipxe.org>
Thu, 15 Jul 2010 19:31:53 +0000 (20:31 +0100)
The DHCP settings registered as a child of the netdevice settings are
not unregistered anywhere.  This prevents the netdevice from being
freed on shutdown.

Fix by automatically unregistering any child settings when the parent
settings are unregistered.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/settings.c

index 427b9ed6c59207ee3c3ea9eb8030f2786d91d08c..79fb8e72a905bfbf4a1e5a0ada7ada00c7c11ce4 100644 (file)
@@ -459,15 +459,22 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
  * @v settings         Settings block
  */
 void unregister_settings ( struct settings *settings ) {
+       struct settings *child;
+       struct settings *tmp;
+
+       /* Unregister child settings */
+       list_for_each_entry_safe ( child, tmp, &settings->children, siblings ) {
+               unregister_settings ( child );
+       }
 
        DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
               settings, settings_name ( settings ) );
 
        /* Remove from list of settings */
-       ref_put ( settings->refcnt );
        ref_put ( settings->parent->refcnt );
        settings->parent = NULL;
        list_del ( &settings->siblings );
+       ref_put ( settings->refcnt );
 
        /* Apply potentially-updated settings */
        apply_settings();