From: Zhenzhong Duan Date: Fri, 22 Jun 2018 11:51:26 +0000 (+0200) Subject: x86/microcode/intel: Fix memleak in save_microcode_patch() X-Git-Tag: Ubuntu-4.15.0-56.62~2615 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=275330e609730b3a01566bd83fcb3173fcf3cc1b;p=mirror_ubuntu-bionic-kernel.git x86/microcode/intel: Fix memleak in save_microcode_patch() BugLink: https://bugs.launchpad.net/bugs/1835845 [ Upstream commit 0218c766263e70795c5eaa17d75ed54bca350950 ] Free useless ucode_patch entry when it's replaced. [ bp: Drop the memfree_patch() two-liner. ] Signed-off-by: Zhenzhong Duan Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Cc: Srinivas REDDY Eeda Link: http://lkml.kernel.org/r/888102f0-fd22-459d-b090-a1bd8a00cb2b@default Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Khalid Elmously --- diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 1c2cfa0644aa..97ccf4c3b45b 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -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); + } } }