From patchwork Wed Jan 16 11:15:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 1987461 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D08093FDD1 for ; Wed, 16 Jan 2013 11:19:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756660Ab3APLTw (ORCPT ); Wed, 16 Jan 2013 06:19:52 -0500 Received: from mail.pripojeni.net ([178.22.112.14]:42117 "EHLO smtp.pripojeni.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756612Ab3APLTw (ORCPT ); Wed, 16 Jan 2013 06:19:52 -0500 Received: from bellona.site ([178.22.112.2]) by smtp.pripojeni.net (Kerio Connect 7.2.2); Wed, 16 Jan 2013 12:15:29 +0100 From: Jiri Slaby To: lenb@kernel.org Cc: rjw@sisk.pl, linux-acpi@vger.kernel.org, jirislaby@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI: check zero length in acpi_rs_get_aml_length Date: Wed, 16 Jan 2013 12:15:28 +0100 Message-Id: <1358334928-9736-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 1.8.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org There is a bug somewhere in the code that does not set the resource length. This makes the loop in acpi_rs_get_aml_length to loop forever. So it is a good thing to have the check even if the bug is fixed. Signed-off-by: Jiri Slaby --- drivers/acpi/acpica/rscalc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c index da178b4..c128f2e 100644 --- a/drivers/acpi/acpica/rscalc.c +++ b/drivers/acpi/acpica/rscalc.c @@ -198,7 +198,8 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed) /* Validate the descriptor type */ - if (resource->type > ACPI_RESOURCE_TYPE_MAX) { + if (resource->type > ACPI_RESOURCE_TYPE_MAX || + WARN_ON(!resource->length)) { return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE); }