Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2571921rdb; Mon, 4 Dec 2023 00:58:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaMf9PxAkhTUBifmioaZzQyA76uXB+TtpaCCQG5jAk+9bpMZHpl907uqVB5xawXV1PCUK6 X-Received: by 2002:a05:6358:520b:b0:170:39fa:af6d with SMTP id b11-20020a056358520b00b0017039faaf6dmr262855rwa.54.1701680297305; Mon, 04 Dec 2023 00:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701680297; cv=none; d=google.com; s=arc-20160816; b=wclq8yXWy5BJX20ZVd9UablMFFGpWSrl7V61C0JPb8pbaTSje8jMJwMCuUjShdTin/ 3sjj82/Dl015wNY8SGvLA9Vy4WEQ4oOo0nvkbhPhDIzwMsWzqfA0hC65KXi21gZgveIV oqMvT/W7JGQ49tN+N08h6KESEF6SjL9r/mwOc0QGytrHJBx3fGCGWpkLVODQTkr2Jx9H zj3BBNDRSfuBob83I4Mf5xQiR0wrru0HHO8RwXCluazbTE86udHWQWgkTRh5QHy0necT Hi2/gQviQfp7Re+5F3uQI/oCfxwWqNG5dUcnVgReQgZ/eYOty0gf4hhAY1ADovf3Cl6u BuVw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=b/y7rNrztt1eQBOOSPt4nF2oWCc37ErsD/o1GSbRGrU=; fh=RvB7DWBlOFSAAw/IhZLvJYsDCYK4Cqyj+geogNhbM1s=; b=QaYoL0q8dyrVYF3B5ZcS+QNu2sS6qpp3ldnrB66cEtmHX2wNwjhYVKEeJE86X89BM9 VuNMh5bikAH1hPGSb1gClmuO/CWV/+A9LjekGKdquO6yzvS2FIRi6VVba1iHZYAHdIHX SF2JCh25PFsSX37vzGYRSUMnwp0/Pcnmm1VAtNaQFVrfME6bqhwxKHFIdSsFfZk4ttDV NoKedknXRJeu0b0iTltRHhB0naqOWfHyw3YRLvx5Gmg2DBVEjQ7NcAm+8qF6c/a/L8uH Rsx9g2HtfAc+UmgnXgrlH8yMpHv2HHLZl6zjItTsAdiEIpOjr8CYwKe1QGD9HL2akDKy Rpxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+dp7dWv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e14-20020a65678e000000b005c673abd811si2603316pgr.254.2023.12.04.00.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=D+dp7dWv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 36E82807D54C; Mon, 4 Dec 2023 00:58:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343720AbjLDI5m (ORCPT + 99 others); Mon, 4 Dec 2023 03:57:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbjLDI5h (ORCPT ); Mon, 4 Dec 2023 03:57:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB4C99B for ; Mon, 4 Dec 2023 00:57:42 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE04CC433C8; Mon, 4 Dec 2023 08:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701680262; bh=+B4GQ4Ad2RTZYOYLrUhnDHag0qxxB1/ZXy/K6xKY/bA=; h=From:To:Cc:Subject:Date:From; b=D+dp7dWvcKGcJaJPPIGbZDvinEx4GUaK4YzxFzHaAferL7MmhKCZcWs8R2ZuWeslQ Jc5QlXFiv2xR/0gKYjqJU54JdNWTMCw7rj+5DMvK2gB1o+EABLaeVAiPN3WZO9acdX 1dvi9NdOASfUuJZDAU3sDXN/s38zb1uXMRkXZKcRjVUGV3vK+nUcajVEAPXK/K4aCg JxvVvA+YdVLw1pibjP/gwfMG8vO6latwCgil8I26X5D9Z3HS58ntlReOQi3B79RDH+ gN5Y9B+Jon6UgcCNJCx2KBvrVYnEzmgYoPIy+EnzckiYh4caSMaOwQPaxHij9FZ5pH LDXG0DM0/2FSg== From: Arnd Bergmann To: Yisen Zhuang , Salil Mehta , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Arnd Bergmann , Jijie Shao , Hao Chen , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] net: hns3: reduce stack usage in hclge_dbg_dump_tm_pri() Date: Mon, 4 Dec 2023 09:57:21 +0100 Message-Id: <20231204085735.4112882-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:58:14 -0800 (PST) From: Arnd Bergmann This function exceeds the stack frame warning limit: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c: In function 'hclge_dbg_dump_tm_pri': drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:1039:1: error: the frame size of 1408 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Use dynamic allocation for the largest stack object instead. It would be nice to rewrite this file to completely avoid the extra buffer and just use the one that was already allocated by debugfs, but that is a much larger change. Signed-off-by: Arnd Bergmann --- v2: fix error handling leak --- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index ff3f8f424ad9..8f94e13c1edf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -981,7 +981,7 @@ static const struct hclge_dbg_item tm_pri_items[] = { static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) { - char data_str[ARRAY_SIZE(tm_pri_items)][HCLGE_DBG_DATA_STR_LEN]; + char *data_str; struct hclge_tm_shaper_para c_shaper_para, p_shaper_para; char *result[ARRAY_SIZE(tm_pri_items)], *sch_mode_str; char content[HCLGE_DBG_TM_INFO_LEN]; @@ -992,8 +992,13 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) if (ret) return ret; + data_str = kcalloc(ARRAY_SIZE(tm_pri_items), HCLGE_DBG_DATA_STR_LEN, + GFP_KERNEL); + if (!data_str) + return -ENOMEM; + for (i = 0; i < ARRAY_SIZE(tm_pri_items); i++) - result[i] = &data_str[i][0]; + result[i] = &data_str[i * HCLGE_DBG_DATA_STR_LEN]; hclge_dbg_fill_content(content, sizeof(content), tm_pri_items, NULL, ARRAY_SIZE(tm_pri_items)); @@ -1002,23 +1007,23 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) for (i = 0; i < pri_num; i++) { ret = hclge_tm_get_pri_sch_mode(hdev, i, &sch_mode); if (ret) - return ret; + goto out; ret = hclge_tm_get_pri_weight(hdev, i, &weight); if (ret) - return ret; + goto out; ret = hclge_tm_get_pri_shaper(hdev, i, HCLGE_OPC_TM_PRI_C_SHAPPING, &c_shaper_para); if (ret) - return ret; + goto out; ret = hclge_tm_get_pri_shaper(hdev, i, HCLGE_OPC_TM_PRI_P_SHAPPING, &p_shaper_para); if (ret) - return ret; + goto out; sch_mode_str = sch_mode & HCLGE_TM_TX_SCHD_DWRR_MSK ? "dwrr" : "sp"; @@ -1035,7 +1040,9 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) pos += scnprintf(buf + pos, len - pos, "%s", content); } - return 0; +out: + kfree(data_str); + return ret; } static const struct hclge_dbg_item tm_qset_items[] = { -- 2.39.2