瀏覽代碼

[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>
tags/v1.20.1
Michael Brown 10 年之前
父節點
當前提交
0af3d14a23
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2
    2
      src/core/settings.c

+ 2
- 2
src/core/settings.c 查看文件

499
  */
499
  */
500
 void unregister_settings ( struct settings *settings ) {
500
 void unregister_settings ( struct settings *settings ) {
501
 	struct settings *child;
501
 	struct settings *child;
502
-	struct settings *tmp;
503
 
502
 
504
 	/* Unregister child settings */
503
 	/* Unregister child settings */
505
-	list_for_each_entry_safe ( child, tmp, &settings->children, siblings ) {
504
+	while ( ( child = list_first_entry ( &settings->children,
505
+					     struct settings, siblings ) ) ) {
506
 		unregister_settings ( child );
506
 		unregister_settings ( child );
507
 	}
507
 	}
508
 
508
 

Loading…
取消
儲存