From patchwork Fri Jul 1 21:21:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 9210495 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 47E5760752 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 38FEB286B3 for ; Fri, 1 Jul 2016 21:23:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AA82286D1; 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=ham 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 A0553286B3 for ; Fri, 1 Jul 2016 21:23:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752571AbcGAVWR (ORCPT ); Fri, 1 Jul 2016 17:22:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbcGAVWP (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 6932792A55; Fri, 1 Jul 2016 21:21:29 +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 u61LLPkP003914; Fri, 1 Jul 2016 17:21:28 -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 2/3] ACPI: fix acpi_parse_entries_array() so it traverses all subtables Date: Fri, 1 Jul 2016 15:21:20 -0600 Message-Id: <1467408081-7418-3-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.28]); Fri, 01 Jul 2016 21:21:29 +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 Without this patch, the acpi_parse_entries_array() function will return the very first time there is any error found in either the array of callback functions or if one of the callbacks returns an non-zero value. However, the array of callbacks could still have valid entries further on in the array, or the callbacks may be able to process subsequent subtables without error. The change here makes the function consistent with its description so that it will properly return the sum of all matching entries for all proc handlers, instead of stopping abruptly as it does today. Signed-off-by: Al Stone Cc: Rafael J. Wysocki Cc: Len Brown --- drivers/acpi/tables.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 3e167b4..76c07ed 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -246,6 +246,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size, struct acpi_subtable_header *entry; unsigned long table_end; int count = 0; + int errs_found = 0; int i; if (acpi_disabled) @@ -278,8 +279,10 @@ acpi_parse_entries_array(char *id, unsigned long table_size, if (entry->type != proc[i].id) continue; if (!proc[i].handler || - proc[i].handler(entry, table_end)) - return -EINVAL; + proc[i].handler(entry, table_end)) { + errs_found++; + continue; + } proc[i].count++; break; @@ -305,7 +308,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size, id, proc->id, count - max_entries, count); } - return count; + return (errs_found) ? -EINVAL : count; } int __init