From: Michael Brown Date: Tue, 3 Mar 2015 00:29:42 +0000 (+0000) Subject: [settings] Use list_first_entry() when unregistering child settings X-Git-Tag: v1.20.1~930 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0af3d14a2379fd7775ef09b5f882682496f7cbe6;p=thirdparty%2Fipxe.git [settings] Use list_first_entry() when unregistering child settings Unregistering a child settings block can have almost arbitrary effects, due to the call to apply_settings(). Avoid potentially dereferencing a stale pointer by using list_first_entry() rather than list_for_each_entry_safe() to iterate over the list of child settings. Signed-off-by: Michael Brown --- diff --git a/src/core/settings.c b/src/core/settings.c index 5e16b27d0..85d95e6eb 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -499,10 +499,10 @@ int register_settings ( struct settings *settings, struct settings *parent, */ 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 ) { + while ( ( child = list_first_entry ( &settings->children, + struct settings, siblings ) ) ) { unregister_settings ( child ); }