Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3031240rwb; Mon, 15 Aug 2022 16:30:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5uoWGFMvJ7gK81ZMUSINvC+h2XiYZY7YKSs0X86kK2R2biVFdiQIKvRCyl8iribfikcxyy X-Received: by 2002:a05:6402:50cb:b0:440:87d4:3ad2 with SMTP id h11-20020a05640250cb00b0044087d43ad2mr16408758edb.219.1660606231588; Mon, 15 Aug 2022 16:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606231; cv=none; d=google.com; s=arc-20160816; b=RQ0gTLh8X1Rl3aa7u9CNecQWfet1LAKR9+NajJZttz0S3d4yYTNW3l7kcy7UD8BVgO JmLoCJGsTGNn2NB/DFYIzNsLhJO+fdeZjpBQUD/n7vJsdXPDMONGp4gZes5xFeuwWJsY /nKhGjUSGi6wEgKXOQNSNJZVHHVZMJ6pL+GdLZLwjgT9i8gHo3e4r/fiSsHbU7URlKhu Z2BUdI6DpStbT0mQgg+iFyvt0uYhBj0C6fTOC7ZpLZyudXAiwaX8E2+lXEWNz9/EPf3V XAbamggb0r8lQX1K7OHh6MMKgMT6HX65FVj72VCkwcUfypUZFisDC/bwtRfGavuNcxJV xlkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6sWid1qxpLso+5RNYDT3cjiTrbNKTh+plgI4m62cvFE=; b=sNZ8NWXNBasejVi7YwtDGUmiKYMRJDyuyszG3IfePc1So12JKGxc+uTEZqNJQwzPIQ n4qYoKJcxLAayZTTBT51kpZaEEAeuN8yDqOK55plfK86p8gnCaxY0JSmvWOwApcUEF4F Qb2vI6TM2eMWY/Mn8TArkED7ZW0zoo6oOWq1l8zKoUstf0xMPsMUWbSiYdfUQMnKX0al thmXXPS7FNHKu6LLNHh7nHnmNGX/6TixZdrzdGVBIBdUoPlXMi6er1Ex6s0Hb/QMpHFC jQzyxVqeEjRK13H0+rrvSsOnFDDT/fPvHyxrQmr+JkbBXg4Dhhu9bZmac7T15YbJzEQH AHeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="IzzGW/4A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r2-20020a056402034200b0043e64d81518si8215120edw.619.2022.08.15.16.30.02; Mon, 15 Aug 2022 16:30:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="IzzGW/4A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353469AbiHOXWR (ORCPT + 99 others); Mon, 15 Aug 2022 19:22:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346068AbiHOXOg (ORCPT ); Mon, 15 Aug 2022 19:14:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C807C193; Mon, 15 Aug 2022 13:02:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E89F26068D; Mon, 15 Aug 2022 20:02:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7524C433C1; Mon, 15 Aug 2022 20:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593722; bh=ztuiYlmLkVZncfWoJY2ReqlKwgNsbOSNGQvAWdyy7tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IzzGW/4AvwkQSF5nL1wqjtmX8Hi6k3BScUm0jgMiyCABX5LVb8LziOZOeB96ypijA uEOJgGsqdHsCRk872WSQnDLkh2/SZAUvR0NH6QCIkPvE6abEgrr6O16mma2scijHjc Slcso2JL3ejLlKdqYXmUo+mT0Om0vKidibOOJLUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Meeta Saggi , Mohamed Khalfella , Bjorn Helgaas , Eric Badger , Sasha Levin Subject: [PATCH 5.18 0996/1095] PCI/AER: Iterate over error counters instead of error strings Date: Mon, 15 Aug 2022 20:06:35 +0200 Message-Id: <20220815180510.317409848@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mohamed Khalfella [ Upstream commit 5e6ae050955b566484f3cc6a66e3925eae87a0ed ] Previously we iterated over AER stat *names*, e.g., aer_correctable_error_string[32], but the actual stat *counters* may not be that large, e.g., pdev->aer_stats->dev_cor_errs[16], which means that we printed junk in the sysfs stats files. Iterate over the stat counter arrays instead of the names to avoid this junk. Also, added a build time check to make sure all counters have entries in strings array. Fixes: 0678e3109a3c ("PCI/AER: Simplify __aer_print_error()") Link: https://lore.kernel.org/r/20220509181441.31884-1-mkhalfella@purestorage.com Reported-by: Meeta Saggi Signed-off-by: Mohamed Khalfella Signed-off-by: Bjorn Helgaas Reviewed-by: Meeta Saggi Reviewed-by: Eric Badger Cc: stable@vger.kernel.org Signed-off-by: Sasha Levin --- drivers/pci/pcie/aer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index 7952e5efd6cf..a1e38ca93cd9 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -538,7 +538,7 @@ static const char *aer_agent_string[] = { u64 *stats = pdev->aer_stats->stats_array; \ size_t len = 0; \ \ - for (i = 0; i < ARRAY_SIZE(strings_array); i++) { \ + for (i = 0; i < ARRAY_SIZE(pdev->aer_stats->stats_array); i++) {\ if (strings_array[i]) \ len += sysfs_emit_at(buf, len, "%s %llu\n", \ strings_array[i], \ @@ -1347,6 +1347,11 @@ static int aer_probe(struct pcie_device *dev) struct device *device = &dev->device; struct pci_dev *port = dev->port; + BUILD_BUG_ON(ARRAY_SIZE(aer_correctable_error_string) < + AER_MAX_TYPEOF_COR_ERRS); + BUILD_BUG_ON(ARRAY_SIZE(aer_uncorrectable_error_string) < + AER_MAX_TYPEOF_UNCOR_ERRS); + /* Limit to Root Ports or Root Complex Event Collectors */ if ((pci_pcie_type(port) != PCI_EXP_TYPE_RC_EC) && (pci_pcie_type(port) != PCI_EXP_TYPE_ROOT_PORT)) -- 2.35.1