* [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()
@ 2017-01-05 0:24 Rafael J. Wysocki
2017-01-05 6:19 ` Paul E. McKenney
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2017-01-05 0:24 UTC (permalink / raw)
To: Linux ACPI
Cc: LKML, Linus Torvalds, Lv Zheng, Robert Moore, Paul E. McKenney, iommu
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Fixes: 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/iommu/dmar.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Index: linux-pm/drivers/iommu/dmar.c
===================================================================
--- linux-pm.orig/drivers/iommu/dmar.c
+++ 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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()
2017-01-05 0:24 [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table() Rafael J. Wysocki
@ 2017-01-05 6:19 ` Paul E. McKenney
2017-01-05 17:41 ` Andy Shevchenko
2017-01-06 1:49 ` Zheng, Lv
2 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2017-01-05 6:19 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, LKML, Linus Torvalds, Lv Zheng, Robert Moore, iommu
On Thu, Jan 05, 2017 at 01:24:14AM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Fixes: 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Much better!
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> ---
> drivers/iommu/dmar.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Index: linux-pm/drivers/iommu/dmar.c
> ===================================================================
> --- linux-pm.orig/drivers/iommu/dmar.c
> +++ 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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()
2017-01-05 0:24 [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table() Rafael J. Wysocki
2017-01-05 6:19 ` Paul E. McKenney
@ 2017-01-05 17:41 ` Andy Shevchenko
2017-01-06 1:49 ` Zheng, Lv
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-01-05 17:41 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, LKML, Linus Torvalds, Lv Zheng, Robert Moore,
Paul E. McKenney, iommu
On Thu, Jan 5, 2017 at 2:24 AM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Fixes: 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/iommu/dmar.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Index: linux-pm/drivers/iommu/dmar.c
> ===================================================================
> --- linux-pm.orig/drivers/iommu/dmar.c
> +++ 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;
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()
2017-01-05 0:24 [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table() Rafael J. Wysocki
2017-01-05 6:19 ` Paul E. McKenney
2017-01-05 17:41 ` Andy Shevchenko
@ 2017-01-06 1:49 ` Zheng, Lv
2 siblings, 0 replies; 4+ messages in thread
From: Zheng, Lv @ 2017-01-06 1:49 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI
Cc: LKML, Linus Torvalds, Moore, Robert, Paul E. McKenney, iommu
Hi, Rafael
> From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi-owner@vger.kernel.org] On Behalf Of Rafael J.
> Wysocki
> Subject: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table()
>
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
>
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Fixes: 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory()
> users")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Thanks for looking into this issue.
The patch fixes the caller side and thus looks very good from my opinion.
Acked-by: Lv Zheng <lv.zheng@intel.com>
Best regards
Lv
> ---
> drivers/iommu/dmar.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Index: linux-pm/drivers/iommu/dmar.c
> ===================================================================
> --- linux-pm.orig/drivers/iommu/dmar.c
> +++ 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;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-06 1:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05 0:24 [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table() Rafael J. Wysocki
2017-01-05 6:19 ` Paul E. McKenney
2017-01-05 17:41 ` Andy Shevchenko
2017-01-06 1:49 ` Zheng, Lv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).