Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1857914rwb; Fri, 19 Aug 2022 10:32:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR6f9s5VrL6UoA6GPRBAtmFcDGanSaL4lyogNX/cxWyef7DsoizzSuGxpNYD+E2LVzBVT2KX X-Received: by 2002:a63:e851:0:b0:42a:3bc0:9ad1 with SMTP id a17-20020a63e851000000b0042a3bc09ad1mr3571316pgk.543.1660930354964; Fri, 19 Aug 2022 10:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930354; cv=none; d=google.com; s=arc-20160816; b=fJKBk20iftTSNKKtjCmkk8rBFIBFOt0MJgt+y/vJHfqfaGlJaT/QNgbFQoCaCwdlKc VuPG4Foa0wfdeljJPmBhVNgC0xFuB3B3ycPcp4dmIt4aG1a0CezleIa8dTDxN7S/rfjT WHgCOtscdusBW0AZjfHzkCvA7eGmO2P7YFiph7Uw7CgXSeA7AhcXOR9p3814kaE1fxgQ 3NBvq7kEC8776ssIc9HkIwLG/aB8gFOsr7Da7aMJyF2Ou3RSiC7r1tEGvzxdoVOlyixj hdCgrFJP8sTCMPP1uLarR/ndsE25krTcL0fMBNKgoIiSjLf4RYOSjX08uobAgcsJdZIu aEbA== 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=k744Inurwx6DI6OtRsKpwc2yNWYS+AY9gM7MkJSWZ9Q=; b=rKci2b04r0HOlvvOyidtrb1KRJkvC9EWfguI8WQl5yLjzgwnYuf7hcvYNbE1DPpk75 L8p9WK/aSDpHzHWOFVaIyUarVo4aTQP1OLPhMXiQvxlsAebz+V8b1RXvjQhitoIo93/u leZsLnw0bR5xJOIBtIBVbHzrLD6UgDFsmJOOPLd0cjB1r0ajC0zNYNgICTsa+fcMYGnG dRvNZtcH7PEOinSJ+D4SRgGHKE2RqIg1EMioWxpePU+5+JECaf9iq6C78GAO6Dc+8vnz UdkFCoce0a9mcMOVZFFU8xi5so+sT9ZqZVPqGhAeqHKbEepDgZt0okYMtaqdZuvM7Uyn ZrhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hC9qG3Xg; 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 k1-20020a170902ce0100b00170d34b95cdsi4458725plg.185.2022.08.19.10.32.23; Fri, 19 Aug 2022 10:32:34 -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=hC9qG3Xg; 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 S1353745AbiHSQq2 (ORCPT + 99 others); Fri, 19 Aug 2022 12:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353775AbiHSQoB (ORCPT ); Fri, 19 Aug 2022 12:44:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EE611231F; Fri, 19 Aug 2022 09:11:17 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2D774B8282A; Fri, 19 Aug 2022 16:10:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7433FC433D6; Fri, 19 Aug 2022 16:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925405; bh=3+8jeA0wp8PJ0PEzbB8vnRQ2Naz3OJjw1F1s8NNDeWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hC9qG3XgcOjS8D5Ok0KS+yTitVJF1sLixSNhcguUSQDXVNROzAjZsf1hlMD7tKUPD F/JwKFcumc/BRhqZDG+z+721ipzlGHVOrFZqax2c+iVRfFvny8EJFUrdGBtqdx6HLK oNkrlzMG+Y3XcEQng6BSdZpDe41MP15p4wMGxyog= 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.10 482/545] PCI/AER: Iterate over error counters instead of error strings Date: Fri, 19 Aug 2022 17:44:12 +0200 Message-Id: <20220819153851.001765437@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 2ab708ab7218..9564b74003f0 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -538,7 +538,7 @@ static const char *aer_agent_string[] = { struct pci_dev *pdev = to_pci_dev(dev); \ u64 *stats = pdev->aer_stats->stats_array; \ \ - 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]) \ str += sprintf(str, "%s %llu\n", \ strings_array[i], stats[i]); \ @@ -1338,6 +1338,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