Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp811217imm; Fri, 22 Jun 2018 05:47:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKo6a8Rt6AMv5R5WjttdtK5siJsyazH7XnxaulvaQPOi+Kbcj5FJ+f7viv4yBM4r1v6Ov6+ X-Received: by 2002:a63:7408:: with SMTP id p8-v6mr1302157pgc.275.1529671667558; Fri, 22 Jun 2018 05:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529671667; cv=none; d=google.com; s=arc-20160816; b=DuCVBPiMN1wsdK1KBhwF1KODW7iwZdUxaV/7z4l6RSDX1X59TIyGt1S4q7WmppDxgL HPkVyMKvIgue5E2aTn94xpQRv7Y0wlOrhW/gE9Tu0te/t30Itj3vC1inTxaSKZz8Xt0z Ze1qbb2TB7mXPPrCHGYNYkaPhO/CjIl6HyEwgqX8/6BGo4/V+4YexaA2kpNfV/J/FaMD cpgBbXuh8lkJIS02UEkPhMkwDs3MVoiUtszA15rtsi0SkhYEs5//evj/+Tau2bGmTImh U0P8gHx4HS/HHkch3aK/6HTNixxZDf6hpMlh9F0FtF4CzY4upaOrk0wBmh6B0vNb09EN mpPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=tUJIkYdpJINXzsOsxOhhXFjx+daKiOZ/+Jv+asUGnxs=; b=cBP9zsD7Mllgqslv99e8QDTw3UeWWVACdmcgGQu2YTyJrq+gLmxonWIQJw9uHuILiY 2gJJcG91lSwZinlIwG7fTBML0Rm0KrOSXNu6PPf64Yl2h77Y7wdMSs9oImFg82dOB08i YsQ9aEXqLxTUrPv/noMRmwUo0CXyAuxE7BzhdSbSw7b8aGNwNxuambAGEBCb5j4JbJA3 BNNG0EDXZO9EUzmc30T7R71nrchPjjKOilvQjGQ5AzZByR+j97HAQAOS7IZPMLxwpFbd Rh1ACqyYgR7JUKq4QEaJm9cedhtlw5huvsgBsUbfOB69UFn5OU7mreynShCBarcNZFfz M9zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3-v6si7276188plb.27.2018.06.22.05.47.28; Fri, 22 Jun 2018 05:47:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754140AbeFVMqC (ORCPT + 99 others); Fri, 22 Jun 2018 08:46:02 -0400 Received: from terminus.zytor.com ([198.137.202.136]:50647 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751315AbeFVMqA (ORCPT ); Fri, 22 Jun 2018 08:46:00 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5MCjkjN071735 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Jun 2018 05:45:46 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5MCjkvT071732; Fri, 22 Jun 2018 05:45:46 -0700 Date: Fri, 22 Jun 2018 05:45:46 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Zhenzhong Duan Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, zhenzhong.duan@oracle.com, bp@suse.de, srinivas.eeda@oracle.com, hpa@zytor.com Reply-To: hpa@zytor.com, bp@suse.de, srinivas.eeda@oracle.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, zhenzhong.duan@oracle.com In-Reply-To: <888102f0-fd22-459d-b090-a1bd8a00cb2b@default> References: <888102f0-fd22-459d-b090-a1bd8a00cb2b@default> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/microcode/intel: Fix memleak in save_microcode_patch() Git-Commit-ID: 0218c766263e70795c5eaa17d75ed54bca350950 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0218c766263e70795c5eaa17d75ed54bca350950 Gitweb: https://git.kernel.org/tip/0218c766263e70795c5eaa17d75ed54bca350950 Author: Zhenzhong Duan AuthorDate: Fri, 22 Jun 2018 13:51:26 +0200 Committer: Thomas Gleixner CommitDate: Fri, 22 Jun 2018 14:42:59 +0200 x86/microcode/intel: Fix memleak in save_microcode_patch() 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 --- arch/x86/kernel/cpu/microcode/intel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); + } } }