Skip to contentSkip to conversation

ACPI / DMAR: Avoid passing NULL to acpi_put_table()

PATCH In review Rafael J. Wysocki 4 participants 4 messages Jan 5, 2017 – Jan 6, 2017

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

PATCH 1/1 ACPI / DMAR: Avoid passing NULL to acpi_put_table()

From: Rafael J. Wysocki <[email protected]>

Linus reported that commit 174cc7187e6f "ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel" added a new warning on his desktop system:

ACPI Warning: Table ffffffff9fe6c0a0, Validation count is zero before decrement

which turns out to come from the acpi_put_table() in detect_intel_iommu().

This happens if the DMAR table is not present in which case NULL is passed to acpi_put_table() which doesn't check against that and attempts to handle it regardless.

For this reason, check the pointer passed to acpi_put_table() before invoking it.

Fixes 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
---
 drivers/iommu/dmar.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iommu/dmar.c +4 -2
Index: linux-pm/drivers/iommu/dmar.c
===================================================================
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
 		x86_init.iommu.iommu_init = intel_iommu_init;
 #endif
 
-	acpi_put_table(dmar_tbl);
-	dmar_tbl = NULL;
+	if (dmar_tbl) {
+		acpi_put_table(dmar_tbl);
+		dmar_tbl = NULL;
+	}
 	up_write(&dmar_global_lock);
 
 	return ret ? 1 : -ENODEV;
Tested-by on v1 1/1
#1 lore raw
Quoted 15 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Linus reported that commit 174cc7187e6f "ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel" added a new warning on his desktop system:

ACPI Warning: Table ffffffff9fe6c0a0, Validation count is zero before decrement

which turns out to come from the acpi_put_table() in detect_intel_iommu().

This happens if the DMAR table is not present in which case NULL is passed to acpi_put_table() which doesn't check against that and attempts to handle it regardless.

Quoted 6 lines

For this reason, check the pointer passed to acpi_put_table() before invoking it.

Fixes 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")

Much better!

Quoted 22 lines
---
 drivers/iommu/dmar.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/iommu/dmar.c
===================================================================

drivers/iommu/dmar.c +4 -2
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
 		x86_init.iommu.iommu_init = intel_iommu_init;
 #endif
 
-	acpi_put_table(dmar_tbl);
-	dmar_tbl = NULL;
+	if (dmar_tbl) {
+		acpi_put_table(dmar_tbl);
+		dmar_tbl = NULL;
+	}
 	up_write(&dmar_global_lock);
 
 	return ret ? 1 : -ENODEV;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Rafael J. Wysocki
Quoted 11 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Linus reported that commit 174cc7187e6f "ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel" added a new warning on his desktop system:

ACPI Warning: Table ffffffff9fe6c0a0, Validation count is zero before decrement

which turns out to come from the acpi_put_table() in detect_intel_iommu().

Quoted 7 lines

This happens if the DMAR table is not present in which case NULL is passed to acpi_put_table() which doesn't check against that and attempts to handle it regardless.

For this reason, check the pointer passed to acpi_put_table() before invoking it.

Quoted 25 lines
Fixes 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
---
 drivers/iommu/dmar.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/iommu/dmar.c
===================================================================

drivers/iommu/dmar.c +4 -2
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
                x86_init.iommu.iommu_init = intel_iommu_init;
 #endif
 
-       acpi_put_table(dmar_tbl);
-       dmar_tbl = NULL;
+       if (dmar_tbl) {
+               acpi_put_table(dmar_tbl);
+               dmar_tbl = NULL;
+       }
        up_write(&dmar_global_lock);
 
        return ret ? 1 : -ENODEV;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Acked-by on v1 1/1
#3 lore raw
In reply to Rafael J. Wysocki

Hi, Rafael

Quoted 19 lines

From: [email protected] [mailto:[email protected]] On Behalf Of Rafael J. Wysocki
Subject: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()

From: Rafael J. Wysocki <[email protected]>

Linus reported that commit 174cc7187e6f "ACPICA: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel" added a new warning on his desktop system:

ACPI Warning: Table ffffffff9fe6c0a0, Validation count is zero before decrement

which turns out to come from the acpi_put_table() in detect_intel_iommu().

This happens if the DMAR table is not present in which case NULL is passed to acpi_put_table() which doesn't check against that and attempts to handle it regardless.

Quoted 7 lines

For this reason, check the pointer passed to acpi_put_table() before invoking it.

Fixes 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory()

users")

Thanks for looking into this issue.
The patch fixes the caller side and thus looks very good from my opinion.

Best regards
Lv

Quoted 26 lines
---
 drivers/iommu/dmar.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/iommu/dmar.c
===================================================================

drivers/iommu/dmar.c +4 -3
@@ -903,8 +903,10 @@ int __init detect_intel_iommu(void)
 		x86_init.iommu.iommu_init = intel_iommu_init;
 #endif
 
-	acpi_put_table(dmar_tbl);
-	dmar_tbl = NULL;
+	if (dmar_tbl) {
+		acpi_put_table(dmar_tbl);
+		dmar_tbl = NULL;
+	}
 	up_write(&dmar_global_lock);
 
 	return ret ? 1 : -ENODEV;
 
--

To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html