public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 9/9] x86/microcode/amd: Add __list_del_entry_valid() in front of __list_del() in free_cache()
@ 2021-09-02  1:45 jiasheng
  0 siblings, 0 replies; 2+ messages in thread
From: jiasheng @ 2021-09-02  1:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: jiasheng

We have found that in the complied files __list_del()
appear more than 100 times, and under at least 90% circumstances
that __list_del_entry_valid() and __list_del() appear in pairs.
For example, they appear together in the __list_del_entry()
of the header file, 'include/linux/list.h'.
But we have found that in the free_cache(), there is only
__list_del() instead of the pair.
Therefore, we consider that the __list_del_entry_valid()
might be forgotten.

Signed-off-by: jiasheng <jiasheng@iscas.ac.cn>
---
 arch/x86/kernel/cpu/microcode/amd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 3d4a483..1987ee1 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -626,6 +626,8 @@ static void free_cache(void)
 	struct ucode_patch *p, *tmp;
 
 	list_for_each_entry_safe(p, tmp, &microcode_cache, plist) {
+		if (!__list_del_entry_valid(p->plist))
+			continue;
 		__list_del(p->plist.prev, p->plist.next);
 		kfree(p->data);
 		kfree(p);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-02  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1630547122-3731091-1-git-send-email-jiasheng@iscas.ac.cn>
2021-09-02  8:38 ` [PATCH 9/9] x86/microcode/amd: Add __list_del_entry_valid() in front of __list_del() in free_cache() Borislav Petkov
2021-09-02  1:45 jiasheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox