From patchwork Fri Jul 1 21:21:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 9210499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC28460752 for ; Fri, 1 Jul 2016 21:23:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDC28286B3 for ; Fri, 1 Jul 2016 21:23:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2A21286CA; Fri, 1 Jul 2016 21:23:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1BA4286C0 for ; Fri, 1 Jul 2016 21:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbcGAVWR (ORCPT ); Fri, 1 Jul 2016 17:22:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44672 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbcGAVWP (ORCPT ); Fri, 1 Jul 2016 17:22:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A4C38826; Fri, 1 Jul 2016 21:21:30 +0000 (UTC) Received: from fidelio.ahs3.com (ovpn-116-22.phx2.redhat.com [10.3.116.22]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u61LLPkQ003914; Fri, 1 Jul 2016 17:21:30 -0400 From: Al Stone To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ahs3@redhat.com, "Rafael J . Wysocki" , Len Brown Subject: [PATCH 3/3] ACPI: fix acpi_parse_entries_array() so it reports overflow correctly Date: Fri, 1 Jul 2016 15:21:21 -0600 Message-Id: <1467408081-7418-4-git-send-email-ahs3@redhat.com> In-Reply-To: <1467408081-7418-1-git-send-email-ahs3@redhat.com> References: <1467408081-7418-1-git-send-email-ahs3@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 01 Jul 2016 21:21:30 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function acpi_parse_entries_array() has a limiting parameter, max_entries, which tells the function to stop looking at subtables once that limit has been reached. Further, if the limit is reached, it is reported. However, the logic is incorrect in that the loop to examine all subtables will always stop when exactly max_entries have been found, regardless of whether or not there are still subtables to examine, and it will always report that zero subtables have been ignored. This change allows the loop to continue to look at all subtables and count all the ones of interest; if we have already reached the number of max_entries, though, we will not invoke the callback functions. If the max_entries limit has been exceeded, report on that, as before, but more accurately, listing how many subtables of interest there are in total (as was meant), and how many entries each subtable type occupied. Signed-off-by: Al Stone Cc: Rafael J. Wysocki Cc: Len Brown --- drivers/acpi/tables.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 76c07ed..227312d 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -272,12 +272,11 @@ acpi_parse_entries_array(char *id, unsigned long table_size, while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < table_end) { - if (max_entries && count >= max_entries) - break; - for (i = 0; i < proc_num; i++) { if (entry->type != proc[i].id) continue; + if (max_entries && count >= max_entries) + break; if (!proc[i].handler || proc[i].handler(entry, table_end)) { errs_found++; @@ -304,8 +303,11 @@ acpi_parse_entries_array(char *id, unsigned long table_size, } if (max_entries && count > max_entries) { - pr_warn("[%4.4s:0x%02x] ignored %i entries of %i found\n", - id, proc->id, count - max_entries, count); + pr_warn("[%4.4s] ignored %i entries of %i found\n", + id, count - max_entries, count); + for (i = 0; i < proc_num; i++) + pr_warn("[%4.4s] subtable 0x%02x used %i entries\n", + id, proc[i].id, proc[i].count); } return (errs_found) ? -EINVAL: count;