Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1295354imu; Wed, 16 Jan 2019 16:37:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN47hNwOy8nND5LuvSTYXsRC3SxkHM50Fff7F9uSedQpbJQ5D/gdKRvtO/1HLRluRLSehBDB X-Received: by 2002:a63:cd11:: with SMTP id i17mr11536045pgg.345.1547685420443; Wed, 16 Jan 2019 16:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685420; cv=none; d=google.com; s=arc-20160816; b=hX5fdC6FtQaswiMb2OM72qblXn9cpOMv2MVLULIo7a6aGpGPSBpdl5INKPGxk/I1mq PINQ+X1Lu7bgb74jM0leoATo9uYO8dFuZaW3OyrGgcy6Pw1KlkUJDqX2Ro9E2Lv8RcU0 Mi3K2yUPZi1c7Y/UqnZZHAq+io6JT19KXU+ttzGzdLGNH7GV169kf6mDhraXFOeFkxHp cNHo0gT+pkPiFjTMRcwiRGsAFiGFYShxsfk1G744ITekRf4NbraX8NLiZxZywGjw0nFu rUJYLwdQh6pFIuipx84+6VqWD6uQ0P2+GL1+UpWD72oBQGJNR4jW5rpVAwNEpYMtWI+4 pigg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=PvEWyr1jueiABDVzXc6weh914m0SseVBk+FTLy7B3LM=; b=eS78SGC+qEolrr9P2MBCDtYhdp8Ml4/zq0cYx+JfWrLme8YKWbemhvu9w4NcXqIMLa ZxbWBTwDfnn+c7yeQbazlx6vb9CewHPBNio4zu4/A7XO874oTKd4CH4K/8f6CkmOrKHX 8Vq/TwunMTt1IoeKUPlzpXk7ly9bJicvq2bRXNAGxhnW/wBU8k4Kl4dDO6qf8uxrCqE9 bBTTvYec2wXL9WB96+i76sujaMDY2Qntwfk9yjEJxOCM0uTekDWSy5IMIXhC28fE0Jya BQG+/x8Y447MA8Ffhq1AVYPM941uBjcmWJwGa3j61PI5JShIZW+hf3NPlU9nSkmHNA7w MwcA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c65si7934886pfe.202.2019.01.16.16.36.42; Wed, 16 Jan 2019 16:37:00 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbfAPUnu (ORCPT + 99 others); Wed, 16 Jan 2019 15:43:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbfAPUnu (ORCPT ); Wed, 16 Jan 2019 15:43:50 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C2949F73B; Wed, 16 Jan 2019 20:43:50 +0000 (UTC) Received: from [10.36.116.103] (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A12519C7E; Wed, 16 Jan 2019 20:43:42 +0000 (UTC) Subject: Re: [PATCH] iommu/intel-iommu: fix memory leak in intel_iommu_put_resv_regions() To: Gerald Schaefer , Joerg Roedel Cc: David Woodhouse , Robin Murphy , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, Alex Williamson References: <20190116191144.15652-1-gerald.schaefer@de.ibm.com> From: Auger Eric Message-ID: Date: Wed, 16 Jan 2019 21:43:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190116191144.15652-1-gerald.schaefer@de.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Jan 2019 20:43:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gerald, On 1/16/19 8:11 PM, Gerald Schaefer wrote: > Commit 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") changed > the reserved region type in intel_iommu_get_resv_regions() from > IOMMU_RESV_RESERVED to IOMMU_RESV_MSI, but it forgot to also change > the type in intel_iommu_put_resv_regions(). > > This leads to a memory leak, because now the check in > intel_iommu_put_resv_regions() for IOMMU_RESV_RESERVED will never > be true, and no allocated regions will be freed. > > Fix this by changing the region type in intel_iommu_put_resv_regions() > to IOMMU_RESV_MSI, matching the type of the allocated regions. > > Fixes: 9d3a4de4cb8d ("iommu: Disambiguate MSI region types") > Cc: # v4.11+ > Signed-off-by: Gerald Schaefer Reviewed-by: Eric Auger Thanks Eric > --- > drivers/iommu/intel-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 048b5ab36a02..b83e0f2025bb 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -5295,7 +5295,7 @@ static void intel_iommu_put_resv_regions(struct device *dev, > struct iommu_resv_region *entry, *next; > > list_for_each_entry_safe(entry, next, head, list) { > - if (entry->type == IOMMU_RESV_RESERVED) > + if (entry->type == IOMMU_RESV_MSI) > kfree(entry); > } > } >