public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Su Hui <suhui@nfschina.com>
Cc: Joerg Roedel <joro@8bytes.org>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	kevin.tian@intel.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/amd: Fix possible memory leak of 'domain'
Date: Wed, 7 Jun 2023 19:56:51 +0530	[thread overview]
Message-ID: <95c1cc02-cd5d-c454-7c29-e4c42a6bd54c@amd.com> (raw)
In-Reply-To: <ZICSskXNlR+ckKvC@ziepe.ca>

Jason,


On 6/7/2023 7:52 PM, Jason Gunthorpe wrote:
> On Tue, Jun 06, 2023 at 03:07:42PM +0800, Su Hui wrote:
>> free memory of domain before return NULL.
>>
>> Fixes: 29f54745f245 ("iommu/amd: Add missing domain type checks")
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
>>  drivers/iommu/amd/iommu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
>> index dc1ec6849775..f08e65629c74 100644
>> --- a/drivers/iommu/amd/iommu.c
>> +++ b/drivers/iommu/amd/iommu.c
>> @@ -2094,7 +2094,7 @@ static struct protection_domain *protection_domain_alloc(unsigned int type)
>>  	} else if (type == IOMMU_DOMAIN_DMA || type == IOMMU_DOMAIN_DMA_FQ) {
>>  		pgtable = amd_iommu_pgtable;
>>  	} else {
>> -		return NULL;
>> +		goto out_err;
>>  	}
> 
> It might be nicer to order to allocation after the type checks, it is
> more consistent with the other drivers
> 
> This is fine too

Right. We are working on cleaning up/re-arranging this code path.
Hopefully I will have patches soon.


-Vasant


      reply	other threads:[~2023-06-07 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  7:07 [PATCH] iommu/amd: Fix possible memory leak of 'domain' Su Hui
2023-06-07  4:19 ` Vasant Hegde
2023-06-07 14:22 ` Jason Gunthorpe
2023-06-07 14:26   ` Vasant Hegde [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95c1cc02-cd5d-c454-7c29-e4c42a6bd54c@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suhui@nfschina.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox