Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3260718rwb; Mon, 15 Aug 2022 22:35:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6gDzFg2rUSovQg8ETKMmxFgdXn6kGoM9OZUnriYvUr9qN8vYUYD7RwxETj3NR4Xu4/phaI X-Received: by 2002:a17:907:6e9f:b0:730:e923:a378 with SMTP id sh31-20020a1709076e9f00b00730e923a378mr12566177ejc.71.1660628118560; Mon, 15 Aug 2022 22:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660628118; cv=none; d=google.com; s=arc-20160816; b=d6QNatXw9LlHa5ZrTZC2nA8XQWRLaFmXDIvNmW02ebv2EZd047asI0zYadiLI4BsbX 23sFzgpl9zTpr3EspxCoSv/c4ebKp8S43MQU2r2Xexe0NkaatHHRZvZ3v9BHTmwzrhix TlxPuKBheSP5k5SQaNVryk3IGGbOiHVz+RGYl3rqt4V4KVI+KTYPDOqs85j87Ygknyt7 zHpi8PE/JcIhzwx2W0yIZJbNuvAYzXVF3wH8X9gDtpBrDi51ZmmTQqyGnfwGvTJFFkqT CRIq2wD68oVjb5Wof0RzCpJnhBjSf/VAxMOE36gXWJgMhUcVtZOUUl0Ka0euGWOF51/P 9aNQ== 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=gKLTmwQj7jiyKiwDVqDH+ijijSNg2IXLqIsPLheaBeQSTA54R/O49mOUySU3hwOA3J ugWyga5HfGAtIAr8XnzNObINt9JfqtyuGnn2EjYvVYN6Ws1zmL72wP66jm9E7DjRd9e1 5FaYj/6ryOd64FyyENqQ2BN2uKh6uohBZyniuXKkki0tPHyU53TfLkq5H1CWb+iLhGL8 21SphCF+P2ffiHFPQOQpaQLUDRXtkhyiTkdT2e+MA4Gzzys3X/VZ+oDHFsL5Whpeoz8+ 1P48W84FWeA4v3YUCCT8zOa5pBQDGQi9zVLZn8aYVholqtSw9XILaMBbift4nwx3MuKO 0fzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hRI0+mbL; 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 dm5-20020a170907948500b00738553043e5si4207935ejc.573.2022.08.15.22.34.52; Mon, 15 Aug 2022 22:35:18 -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=hRI0+mbL; 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 S232112AbiHPExW (ORCPT + 99 others); Tue, 16 Aug 2022 00:53:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232947AbiHPEuA (ORCPT ); Tue, 16 Aug 2022 00:50:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A8D0199B00; Mon, 15 Aug 2022 13:46:36 -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 B12466122E; Mon, 15 Aug 2022 20:46:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E999C433D6; Mon, 15 Aug 2022 20:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596395; bh=ztuiYlmLkVZncfWoJY2ReqlKwgNsbOSNGQvAWdyy7tc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hRI0+mbLndZAT1BxGjuaPMBj2RpM3MWPzzm4yS1f2wLbJ5Lz5tr4tANR2bM2oAHGF YmMct2s5U7x0RjlZal45NVpV0rbDJbPX7cKMaxbHQyEbsixu4ynWAATLAOxzr9zMJl Pwy5cL8ibo7hNJUvQKsI0quDbayAHr9LXpFb976g= 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.19 1066/1157] PCI/AER: Iterate over error counters instead of error strings Date: Mon, 15 Aug 2022 20:07:02 +0200 Message-Id: <20220815180522.727862498@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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