From patchwork Wed Oct 7 21:49:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 7347421 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7174CBEEA4 for ; Wed, 7 Oct 2015 21:50:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B564E20626 for ; Wed, 7 Oct 2015 21:50:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86A4D20622 for ; Wed, 7 Oct 2015 21:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755127AbbJGVuA (ORCPT ); Wed, 7 Oct 2015 17:50:00 -0400 Received: from mga03.intel.com ([134.134.136.65]:54372 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893AbbJGVt7 (ORCPT ); Wed, 7 Oct 2015 17:49:59 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 07 Oct 2015 14:49:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,651,1437462000"; d="scan'208";a="659904266" Received: from omniknight.lm.intel.com ([10.232.112.76]) by orsmga003.jf.intel.com with ESMTP; 07 Oct 2015 14:49:55 -0700 From: Vishal Verma To: linux-nvdimm@lists.01.org Cc: Vishal Verma , Dan Williams , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org Subject: [PATCH 1/3] nfit: in acpi_nfit_init, break on a 0-length table Date: Wed, 7 Oct 2015 15:49:35 -0600 Message-Id: <1444254577-23744-2-git-send-email-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444254577-23744-1-git-send-email-vishal.l.verma@intel.com> References: <1444254577-23744-1-git-send-email-vishal.l.verma@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If acpi_nfit_init is called (such as from nfit_test), with an nfit table that has more memory allocated than it needs (and a similarly large 'size' field, add_tables would happily keep adding null SPA Range tables filling up all available memory. Make it friendlier by breaking out if a 0-length header is found in any of the tables. Cc: Dan Williams Cc: Rafael J. Wysocki Cc: Cc: Signed-off-by: Vishal Verma --- drivers/acpi/nfit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index c1b8d03..ed599d1 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -335,6 +335,9 @@ static void *add_table(struct acpi_nfit_desc *acpi_desc, void *table, return NULL; hdr = table; + if (!hdr->length) + return NULL; + switch (hdr->type) { case ACPI_NFIT_TYPE_SYSTEM_ADDRESS: if (!add_spa(acpi_desc, table))