Skip to contentSkip to conversation

x86/microcode/intel: Fix memleak in save_microcode_patch()

PATCH New Borislav Petkov 1 participant 1 message Jun 22, 2018

Subsystems (2)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 x86/microcode/intel: Fix memleak in save_microcode_patch()

From: Zhenzhong Duan <[email protected]>

Free useless ucode_patch entry when it's replaced.

---
 arch/x86/kernel/cpu/microcode/intel.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/intel.c +4 -1
index 1c2cfa0644aa..97ccf4c3b45b 100644
@@ -190,8 +190,11 @@ static void save_microcode_patch(void *data, unsigned int size)
 			p = memdup_patch(data, size);
 			if (!p)
 				pr_err("Error allocating buffer %p\n", data);
-			else
+			else {
 				list_replace(&iter->plist, &p->plist);
+				kfree(iter->data);
+				kfree(iter);
+			}
 		}
 	}
 
Signature · 1 line
2.17.0.582.gccdcbd54c