david/ipxe
Archived
1
0

[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 <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2015-03-03 00:29:42 +00:00
parent e399fc0d21
commit 0af3d14a23

View File

@ -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 );
}