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,15 +459,22 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
459 459
  * @v settings		Settings block
460 460
  */
461 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 470
 	DBGC ( settings, "Settings %p (\"%s\") unregistered\n",
464 471
 	       settings, settings_name ( settings ) );
465 472
 
466 473
 	/* Remove from list of settings */
467
-	ref_put ( settings->refcnt );
468 474
 	ref_put ( settings->parent->refcnt );
469 475
 	settings->parent = NULL;
470 476
 	list_del ( &settings->siblings );
477
+	ref_put ( settings->refcnt );
471 478
 
472 479
 	/* Apply potentially-updated settings */
473 480
 	apply_settings();

Loading…
Cancel
Save