From patchwork Mon Sep 27 09:49:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514670 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp3945126jao; Mon, 27 Sep 2021 02:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiYbmT2eVHHOAAlGT0bFcYF3ytzvWVUyX7TChUtFKUMknKeKNWCcf9FtZhUQddWX+hwAGF X-Received: by 2002:a17:906:4f82:: with SMTP id o2mr26431835eju.10.1632736215834; Mon, 27 Sep 2021 02:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632736215; cv=none; d=google.com; s=arc-20160816; b=fHmOOptWCrXmRfGo6xFUHsRBe+mDe8I5LtMDSX3M+NTEYhmUkVAyZrgdXrW8BMM2sR odKtZSVQOaUbR4JzCQnEghUqFjHIri8UprlljtmEXUXFnKCQT8QdHv9Sn76jgQjJeT3x g9o303akUzmix7KCxq9QoCwi/XqJukTsZgDvIJMEki3mNjhYB084+HKUyWRQlV1Stu/K R8nLPq9WB4uIdvB9lqV2vHAyh47P/3KBfBGL8f0PTOF3lFhuEDrj3XIrO0jmzFmGfc76 H47CXVXZnXzc/bwyhVpX/UGixftsO5zUhBWLuE+gdl1tFHu0JbuItr/heiYrshnl58PJ T+Rg== 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=5ZKMricn0XzFyn9ldI8g4twMOj2oiQiQu137MjLd++o=; b=l9JPdBjw+DX1qhOswxPLkdBYaLHSfbIlVZIMWq9VmUPW29Oqx8bz0+CDQ+SsDecDLE 6CdSd8zdU3JtDNNGFpotjTXm4yTAHfnbUiym4TyBoFEDgKw36dfO+k3MZqrYfyBz6Hbq tLUOREAHuYWSH6ZO/R4y1KcDPJOgNLhFZebDKP0d80wTrVWE54hVzC1GvLK4zurMHLQm nUUEkcFxqox5u4Q2oXC9udhYzqzxUj730iS1hl0NGSmuvJEzcz+NBUduLWrkFqwqaaUl c4jA6FRTVkLRFiiREPggORChboKMFI6leqITAx74GHVCbKuxffWYTYXCrzvxiadLCtOQ 9jWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j2wTL+cZ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d12si17344302ejj.278.2021.09.27.02.50.15; Mon, 27 Sep 2021 02:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j2wTL+cZ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233729AbhI0Jvt (ORCPT + 8 others); Mon, 27 Sep 2021 05:51:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:51534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233680AbhI0Jvs (ORCPT ); Mon, 27 Sep 2021 05:51:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1E0EB60F70; Mon, 27 Sep 2021 09:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632736211; bh=KtQwfWlN6z5FTUvVzqtdfbSOfg7sCBGIIuVYv4bnZ3w=; h=From:To:Cc:Subject:Date:From; b=j2wTL+cZYs1v6vTzwrd/UiAQ2VH9c5ySHLrMAo0w+GhBLH87jiejo5Nm+BgPed/pp vOVce62at6PxEw8g+8Oyazob2aL3C/X4x/ULopOIVWnL26G+Pju1Yf/snTnYeWf0l7 4Wx5cnJVmtD3CGhoYVZYnm0y+VFFdS8dVajdTl8SwY4hdHcwCoEnF8M/+LC4pGIQkf tZpduSADVwAooNALtbZDd1FwgZUH+lQn6L954EcWfeb8js4RVdzWwjbhaWwthfosAl uu3N7KYkpizPTGlMTQrRk067fxR3WezmFHKu0heNH5VshsxowYZT1m8O+ehSJb1a50 ZJnpz0QXtNbMg== From: Arnd Bergmann To: Yisen Zhuang , Salil Mehta , "David S. Miller" , Jakub Kicinski , Guangbin Huang Cc: Arnd Bergmann , Huazhong Tan , Yufeng Mo , Jiaran Zhang , Jian Shen , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: hns3: fix hclge_dbg_dump_tm_pg() stack usage Date: Mon, 27 Sep 2021 11:49:53 +0200 Message-Id: <20210927095006.868305-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann This function copies strings around between multiple buffers including a large on-stack array that causes a build warning on 32-bit systems: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c: In function 'hclge_dbg_dump_tm_pg': drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:782:1: error: the frame size of 1424 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] The function can probably be cleaned up a lot, to go back to printing directly into the output buffer, but dynamically allocating the structure is a simpler workaround for now. Fixes: 04d96139ddb3 ("net: hns3: refine function hclge_dbg_dump_tm_pri()") Signed-off-by: Arnd Bergmann --- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) -- 2.29.2 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 87d96f82c318..3ed87814100a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -719,9 +719,9 @@ static void hclge_dbg_fill_shaper_content(struct hclge_tm_shaper_para *para, sprintf(result[(*index)++], "%6u", para->rate); } -static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) +static int __hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *data_str, + char *buf, int len) { - char data_str[ARRAY_SIZE(tm_pg_items)][HCLGE_DBG_DATA_STR_LEN]; struct hclge_tm_shaper_para c_shaper_para, p_shaper_para; char *result[ARRAY_SIZE(tm_pg_items)], *sch_mode_str; u8 pg_id, sch_mode, weight, pri_bit_map, i, j; @@ -729,8 +729,10 @@ static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) int pos = 0; int ret; - for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++) - result[i] = &data_str[i][0]; + for (i = 0; i < ARRAY_SIZE(tm_pg_items); i++) { + result[i] = data_str; + data_str += HCLGE_DBG_DATA_STR_LEN; + } hclge_dbg_fill_content(content, sizeof(content), tm_pg_items, NULL, ARRAY_SIZE(tm_pg_items)); @@ -781,6 +783,22 @@ static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) return 0; } +static int hclge_dbg_dump_tm_pg(struct hclge_dev *hdev, char *buf, int len) +{ + int ret; + char *data_str = kcalloc(ARRAY_SIZE(tm_pg_items), + HCLGE_DBG_DATA_STR_LEN, GFP_KERNEL); + + if (!data_str) + return -ENOMEM; + + ret = __hclge_dbg_dump_tm_pg(hdev, data_str, buf, len); + + kfree(data_str); + + return ret; +} + static int hclge_dbg_dump_tm_port(struct hclge_dev *hdev, char *buf, int len) { struct hclge_tm_shaper_para shaper_para;