Skip to content

Commit

Permalink
[settings] Unregister the children when unregistering the parent
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pjaroszynski authored and mcb30 committed Jul 15, 2010
1 parent f033694 commit 519a4be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/settings.c
Expand Up @@ -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();
Expand Down

0 comments on commit 519a4be

Please sign in to comment.