Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp183156imm; Thu, 31 May 2018 21:52:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIvUGYawSsSplSSLKDwz/xmAyiz6x2hzhj0JVoZW37P9dT+AIq1WxC5i73TC39WW8AiJrh X-Received: by 2002:a17:902:329:: with SMTP id 38-v6mr9770228pld.328.1527828772759; Thu, 31 May 2018 21:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527828772; cv=none; d=google.com; s=arc-20160816; b=WmWI6WVQ0GeLb+t9Q4QlIVI3oeRye8pFSmAy7oohAWcPFjOg70M8bwBFQGHawWAXYC Jyh5lFFYC7kKiEdvYvjJLoJ68Lvjz8wd27gOoUEoVPQO6j6jiG3XugIa642/YBColt3v 3dkW+nlRrS9OIkqJaFRbh3J7Gwl0Yca0TP9gGEh0iZxNpFVihc8UY5rLay9I2Be0qUvr J3eWLAi3kz1GKwcoRBvr4opZFGo4WcP8NVk5kpgv983NPzb7zLOKRuVz3gknLVuj7NMp 8a+jbAyLZWi+X/fY3wCr80hfeSz/5RwtvIu6WsdX4jhz+gBxHENx+vN+t3J6WWxlp3g8 M6dQ== 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:subject:cc:to:from:date:message-id :mime-version:dkim-signature:arc-authentication-results; bh=640CAgmU9Sf0ENTUHBakVY+DZxA7UDZDr6xLgmtGus4=; b=YkhqYp7JERDpuzHcaZZOZjyW1tbEGEkhBZtAtqavrtJGOUBD7aY2zn4Itm3ZFsuTgV OU4w5QPIGToZG3qgIMIXDfXoKvjgE8WrLU/Bt5pgVOr8d54DZxHsZHl9OGCoKpCaC9/8 UB1H+OhQvomaDNRYArpq5Ogm2XWqpFXpsqxpmWrbFl4dDBQAxYWvUU5sJeUo0UUczUwc rlYDfHEpb+nUvAZ3X/3qCdHTPyt5DpG2Td7nc9mtw9PJ38dpPIbYplvPOHhyUYaJcmnv +fsm3qCNj2ORS6WEEaRrNyK2WsThfkZcBwF1LA465+nNDvCs3gXMAcvY5i15UqVGcZEh z4Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=miVcEkCZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7-v6si39391730plb.73.2018.05.31.21.52.38; Thu, 31 May 2018 21:52:52 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=miVcEkCZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751501AbeFAEvn (ORCPT + 99 others); Fri, 1 Jun 2018 00:51:43 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:57886 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbeFAEvm (ORCPT ); Fri, 1 Jun 2018 00:51:42 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w514oa3E163079; Fri, 1 Jun 2018 04:51:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : to : cc : subject : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=640CAgmU9Sf0ENTUHBakVY+DZxA7UDZDr6xLgmtGus4=; b=miVcEkCZotSev2Jb7OLKEVRm3DXQx/71FvfBvg0MjYhAG+l32VcBtgb1W0cvhufU6qD+ VyxbR2NTSJxw4rsvJh+NI08iKMuLpX5ekTRoe1zxs8N6/hudVke/khOn34Ii25pu9Gti ZGHP3xKTRoaeLcejCqleZ+vAhHkwrJZPS/6btJxLqTsWaznuoYLH8W0g6OAckUcyN4wN tM+3XjhEBp/bVrCxUJuBlrM9uIBDx5kM8DgvIxxYI6QmnkaGS7l6wOizWfFREFfPIuwr kAjqTLWQJDXL9+AhCLCqHsvhcOKewPPPIDYh4kfNkefIR4x4sWyHS3zoZMTMwltVwlBf FA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2janje2467-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Jun 2018 04:51:08 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w514p76T028964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Jun 2018 04:51:07 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w514p5mD022988; Fri, 1 Jun 2018 04:51:05 GMT MIME-Version: 1.0 Message-ID: <888102f0-fd22-459d-b090-a1bd8a00cb2b@default> Date: Thu, 31 May 2018 21:51:05 -0700 (PDT) From: Zhenzhong Duan To: Cc: , , Srinivas REDDY Eeda , , Subject: [PATCH] x86/microcode/intel: Fix memleak in save_microcode_patch X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8910 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=724 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806010053 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Free useless ucode_patch entry when it's replaced. Signed-off-by: Zhenzhong Duan --- arch/x86/kernel/cpu/microcode/intel.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/mi= crocode/intel.c index 1c2cfa0..461e315 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -150,6 +150,12 @@ static bool microcode_matches(struct microcode_header_= intel *mc_header, =09return false; } =20 +static void memfree_patch(struct ucode_patch *p) +{ +=09kfree(p->data); +=09kfree(p); +} + static struct ucode_patch *memdup_patch(void *data, unsigned int size) { =09struct ucode_patch *p; @@ -190,8 +196,10 @@ static void save_microcode_patch(void *data, unsigned = int size) =09=09=09p =3D memdup_patch(data, size); =09=09=09if (!p) =09=09=09=09pr_err("Error allocating buffer %p\n", data); -=09=09=09else +=09=09=09else { =09=09=09=09list_replace(&iter->plist, &p->plist); +=09=09=09=09memfree_patch(iter); +=09=09=09} =09=09} =09} =20 --=20 1.7.1