Browse Source

[settings] Unregister the children when unregistering the parent

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>
tags/v1.20.1
Piotr Jaroszyński 14 years ago
parent
commit
519a4be189
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      src/core/settings.c

+ 8
- 1
src/core/settings.c View File

459
  * @v settings		Settings block
459
  * @v settings		Settings block
460
  */
460
  */
461
 void unregister_settings ( struct settings *settings ) {
461
 void unregister_settings ( struct settings *settings ) {
462
+	struct settings *child;
463
+	struct settings *tmp;
464
+
465
+	/* Unregister child settings */
466
+	list_for_each_entry_safe ( child, tmp, &settings->children, siblings ) {
467
+		unregister_settings ( child );
468
+	}
462
 
469
 
463
 	DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
470
 	DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
464
 	       settings, settings_name ( settings ) );
471
 	       settings, settings_name ( settings ) );
465
 
472
 
466
 	/* Remove from list of settings */
473
 	/* Remove from list of settings */
467
-	ref_put ( settings->refcnt );
468
 	ref_put ( settings->parent->refcnt );
474
 	ref_put ( settings->parent->refcnt );
469
 	settings->parent = NULL;
475
 	settings->parent = NULL;
470
 	list_del ( &settings->siblings );
476
 	list_del ( &settings->siblings );
477
+	ref_put ( settings->refcnt );
471
 
478
 
472
 	/* Apply potentially-updated settings */
479
 	/* Apply potentially-updated settings */
473
 	apply_settings();
480
 	apply_settings();

Loading…
Cancel
Save