Skip to contentSkip to conversation

Intel IOMMU: fix sysfs leak in hotplug init path

PATCH In review Rolf Eike Beer 2 participants 6 messages Apr 21, 2021 – May 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Intel IOMMU: fix sysfs leak in hotplug init path

---
 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.

drivers/iommu/intel/dmar.c +3 -1
index d5c51b5c20af..fb37a9b79b3a 100644
@@ -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:
Signature · 11 lines
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
maintainer
#1 lore raw

Hi Rolf,

Quoted 1 line · Rolf Eike Beer

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")
Quoted 22 lines
---
  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.

drivers/iommu/intel/dmar.c +1 -1
index d5c51b5c20af..fb37a9b79b3a 100644
@@ -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;

drivers/iommu/intel/dmar.c static int alloc_iommu(struct dmar_drhd_unit *drhd) · line 1159

Quoted 8 lines
drivers/iommu/intel/dmar.c +2 -0
@@ -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
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#2 lore raw

PATCH 1/1 iommu/vt-d: Fix sysfs leak in alloc_domain()

In reply to Rolf Eike Beer

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
---
 drivers/iommu/intel/dmar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +3 -1
index d5c51b5c20af..c2bfccb19e24 100644
@@ -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:
Signature · 10 lines
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
maintainer Acked-by on v1 1/1
#3 lore raw

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

Hi Rolf,

Quoted 6 lines · Rolf Eike Beer

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

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

Best regards,
baolu

Quoted 27 lines
---
  drivers/iommu/intel/dmar.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +3 -1
index d5c51b5c20af..c2bfccb19e24 100644
@@ -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:
#4 lore raw

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

Am Donnerstag, 22. April 2021, 07:34:17 CEST schrieb Lu Baolu:

Quoted 11 lines

Hi Rolf,

Quoted 6 lines · Rolf Eike Beer

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

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

Eike

Signature · 7 lines
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

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer
#5 lore raw

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

Hi Joerg,

Quoted 7 lines · Rolf Eike Beer

Am Donnerstag, 22. April 2021, 07:34:17 CEST schrieb Lu Baolu:

Quoted 6 lines

Hi Rolf,

Quoted 3 lines · Rolf Eike Beer

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

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes 39ab9555c2411 ("iommu: Add sysfs bindings for struct iommu_device")
Cc [email protected] # 4.11.x

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
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu