From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258AbdAEGU5 (ORCPT ); Thu, 5 Jan 2017 01:20:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33286 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752698AbdAEGUC (ORCPT ); Thu, 5 Jan 2017 01:20:02 -0500 Date: Wed, 4 Jan 2017 22:19:57 -0800 From: "Paul E. McKenney" To: "Rafael J. Wysocki" Cc: Linux ACPI , LKML , Linus Torvalds , Lv Zheng , Robert Moore , iommu@lists.linux-foundation.org Subject: Re: [PATCH] ACPI / DMAR: Avoid passing NULL to acpi_put_table() Reply-To: paulmck@linux.vnet.ibm.com References: <3112193.PjflRgTHFW@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3112193.PjflRgTHFW@aspire.rjw.lan> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17010506-0008-0000-0000-0000067CAE39 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006376; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00803746; UDB=6.00391048; IPR=6.00581593; BA=6.00005030; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013828; XFM=3.00000011; UTC=2017-01-05 06:20:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17010506-0009-0000-0000-00003E620A83 Message-Id: <20170105061957.GB3742@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-05_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701050103 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 05, 2017 at 01:24:14AM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > 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 > Fixes: 6b11d1d67713 ("ACPI / osl: Remove acpi_get_table_with_size()/early_acpi_os_unmap_memory() users") > Signed-off-by: Rafael J. Wysocki Much better! Tested-by: Paul E. McKenney > --- > 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; >