lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f9151732-50e0-4e6d-8087-3270c9069ea8@linux.alibaba.com>
Date: Sat, 15 Feb 2025 10:06:44 +0800
From: Shuai Xue <xueshuai@...ux.alibaba.com>
To: Vinicius Costa Gomes <vinicius.gomes@...el.com>, fenghua.yu@...el.com,
 dave.jiang@...el.com, vkoul@...nel.org
Cc: dmaengine@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 5/5] dmaengine: idxd: fix memory leak in error handling
 path of idxd_pci_probe



在 2025/2/15 07:41, Vinicius Costa Gomes 写道:
> Shuai Xue <xueshuai@...ux.alibaba.com> writes:
> 
>> Memory allocated for idxd is not freed if an error occurs during
>> idxd_pci_probe(). To fix it, free the allocated memory in the reverse
>> order of allocation before exiting the function in case of an error.
>>
>> Signed-off-by: Shuai Xue <xueshuai@...ux.alibaba.com>
>> ---
>>   drivers/dma/idxd/init.c | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
>> index f0e3244d630d..9b44f5d38d3a 100644
>> --- a/drivers/dma/idxd/init.c
>> +++ b/drivers/dma/idxd/init.c
>> @@ -548,6 +548,14 @@ static void idxd_read_caps(struct idxd_device *idxd)
>>   		idxd->hw.iaa_cap.bits = ioread64(idxd->reg_base + IDXD_IAACAP_OFFSET);
>>   }
>>   
>> +static void idxd_free(struct idxd_device *idxd)
>> +{
>> +	put_device(idxd_confdev(idxd));
>> +	bitmap_free(idxd->opcap_bmap);
>> +	ida_free(&idxd_ida, idxd->id);
>> +	kfree(idxd);
>> +}
>> +
> 
> I was expecting this function to be called from idxd_remove() as well.
> Perhaps on a separate patch?

You are right, I missed the idxd_remove() to destroy idxd device.
Will add a new patch in next version.

> 
>>   static struct idxd_device *idxd_alloc(struct pci_dev *pdev, struct idxd_driver_data *data)
>>   {
>>   	struct device *dev = &pdev->dev;
>> @@ -820,7 +828,7 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>>    err:
>>   	pci_iounmap(pdev, idxd->reg_base);
>>    err_iomap:
>> -	put_device(idxd_confdev(idxd));
>> +	idxd_free(idxd);
>>    err_idxd_alloc:
>>   	pci_disable_device(pdev);
>>   	return rc;
>> -- 
>> 2.39.3
>>
> 
> Cheers,

Thanks.
Shuai


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ