2021-04-21 22:45:00

by Rolf Eike Beer

[permalink] [raw]
Subject: [PATCH] Intel IOMMU: fix sysfs leak in hotplug init path

Signed-off-by: Rolf Eike Beer <[email protected]>
---
drivers/iommu/intel/dmar.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

I have not actually tested this but I guess it should match the code in
free_iommu() just below.

diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index d5c51b5c20af..fb37a9b79b3a 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)

err = iommu_device_register(&iommu->iommu);
if (err)
- goto err_unmap;
+ goto err_unregister;
}

drhd->iommu = iommu;
@@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)

return 0;

+err_unregister:
+ iommu_device_sysfs_remove(&iommu->iommu);
err_unmap:
unmap_iommu(iommu);
error_free_seq_id:
--
2.31.1


--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source




2021-04-22 02:58:09

by Baolu Lu

[permalink] [raw]
Subject: Re: [PATCH] Intel IOMMU: fix sysfs leak in hotplug init path

Hi Rolf,

On 4/21/21 11:12 PM, Rolf Eike Beer wrote:
> Signed-off-by: Rolf Eike Beer <[email protected]>

Thanks for the patch!

Can you please adjust the subject to "iommu/vt-d: Fix sysfs leak in
alloc_domain()"? It's not only for hotplug path.

Please also add commit message.

Add below Fixes tag as well:

Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")

> ---
> drivers/iommu/intel/dmar.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> I have not actually tested this but I guess it should match the code in
> free_iommu() just below.
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index d5c51b5c20af..fb37a9b79b3a 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
>
> err = iommu_device_register(&iommu->iommu);
> if (err)
> - goto err_unmap;
> + goto err_unregister;
> }
>
> drhd->iommu = iommu;
> @@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
>
> return 0;
>
> +err_unregister:
> + iommu_device_sysfs_remove(&iommu->iommu);
> err_unmap:
> unmap_iommu(iommu);
> error_free_seq_id:
>

Best regards,
baolu

2021-04-22 05:42:27

by Rolf Eike Beer

[permalink] [raw]
Subject: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain()

iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent
errors.

Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")
Cc: [email protected] # 4.11.x
Signed-off-by: Rolf Eike Beer <[email protected]>
---
drivers/iommu/intel/dmar.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index d5c51b5c20af..c2bfccb19e24 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)

err = iommu_device_register(&iommu->iommu);
if (err)
- goto err_unmap;
+ goto err_sysfs;
}

drhd->iommu = iommu;
@@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)

return 0;

+err_sysfs:
+ iommu_device_sysfs_remove(&iommu->iommu);
err_unmap:
unmap_iommu(iommu);
error_free_seq_id:
--
2.31.1

--
Rolf Eike Beer, emlix GmbH, https://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source


2021-04-22 05:47:28

by Baolu Lu

[permalink] [raw]
Subject: Re: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain()

Hi Rolf,

On 4/22/21 1:39 PM, Rolf Eike Beer wrote:
> iommu_device_sysfs_add() is called before, so is has to be cleaned on subsequent
> errors.
>
> Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")
> Cc: [email protected] # 4.11.x
> Signed-off-by: Rolf Eike Beer <[email protected]>

Acked-by: Lu Baolu <[email protected]>

P.S. Next time when you submit a new version, please use a version tag.

Best regards,
baolu

> ---
> drivers/iommu/intel/dmar.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index d5c51b5c20af..c2bfccb19e24 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -1144,7 +1144,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
>
> err = iommu_device_register(&iommu->iommu);
> if (err)
> - goto err_unmap;
> + goto err_sysfs;
> }
>
> drhd->iommu = iommu;
> @@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
>
> return 0;
>
> +err_sysfs:
> + iommu_device_sysfs_remove(&iommu->iommu);
> err_unmap:
> unmap_iommu(iommu);
> error_free_seq_id:
>

2021-05-21 10:00:21

by Rolf Eike Beer

[permalink] [raw]
Subject: Re: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain()

Am Donnerstag, 22. April 2021, 07:34:17 CEST schrieb Lu Baolu:
> Hi Rolf,
>
> On 4/22/21 1:39 PM, Rolf Eike Beer wrote:
> > iommu_device_sysfs_add() is called before, so is has to be cleaned on
> > subsequent errors.
> >
> > Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")
> > Cc: [email protected] # 4.11.x
> > Signed-off-by: Rolf Eike Beer <[email protected]>
>
> Acked-by: Lu Baolu <[email protected]>

Ping. Who is going to pick this up, please?

Eike
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source


Attachments:
signature.asc (321.00 B)
This is a digitally signed message part.

2021-05-21 10:04:38

by Baolu Lu

[permalink] [raw]
Subject: Re: [PATCH] iommu/vt-d: Fix sysfs leak in alloc_domain()

Hi Joerg,

On 5/21/21 2:53 PM, Rolf Eike Beer wrote:
> Am Donnerstag, 22. April 2021, 07:34:17 CEST schrieb Lu Baolu:
>> Hi Rolf,
>>
>> On 4/22/21 1:39 PM, Rolf Eike Beer wrote:
>>> iommu_device_sysfs_add() is called before, so is has to be cleaned on
>>> subsequent errors.
>>>
>>> Fixes: 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")
>>> Cc: [email protected] # 4.11.x
>>> Signed-off-by: Rolf Eike Beer <[email protected]>
>>
>> Acked-by: Lu Baolu <[email protected]>
>
> Ping. Who is going to pick this up, please?

I forgot to put this fix in my last pull request. Could you please pick
it up? Or, I can send another pull request the next week.

Best regards,
baolu