From patchwork Tue Sep 28 08:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514771 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp4926684jao; Tue, 28 Sep 2021 01:59:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrVlXxQfTz8kmqy48K3+VyGM+JxBHvnwHsUUldUzW1LvfA3GdNoh6AEoxbp3/9K1DCte6x X-Received: by 2002:aa7:9e9a:0:b0:43e:d9b:cd93 with SMTP id p26-20020aa79e9a000000b0043e0d9bcd93mr4278077pfq.50.1632819561803; Tue, 28 Sep 2021 01:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632819561; cv=none; d=google.com; s=arc-20160816; b=VM9V3U2WExeV7MAiQyhLRkLAMKR82fOvvvYEjUgKMif5dBnZlOuezRZSSxyKnOA2Ta sYiWPD3cj72f3DqJi8OK15lkoKcjVJOeiokqMgmyKZjeWJ9bR6qR8PHovt90d2iUQvyn cVBDIjUNfrZumFn/JObasU2g2D8NvgBuUVasO34MjfOiNrEvKizkjViK601sPYF3sAS+ PA5In3kXUKWIKuSOxDqji+6hI9z6zSF16O49SOsKeI4CTc/fbWNJwrWcN2J+ULEZUtE1 YyYYK/HgP5rQ7GmJr78v8VHpcCtYnTku0mY9c0oom7XqrfIJTCOmbBb5p7pEPulsybop a2xA== 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=cLaypuQs7ZMKm0F99berGKubaj15Et7IsKLA5CAnBhk=; b=n6bfAEX7GeBM18eVluP+9UrAbdE/gR4yi1BvU5sbW4vjvE90cLFyZ1falw3aP4I+/t 0lXllwaP6ihb3+1KnAeZ82ccEM9cvYdoBqcENwikCIjyQEObx5tG8qsSiScJSXjpmuvA Nxh+l3Rjd67hCr+qDxYxX4O/g/7ATRpd1JVb3p/Rgj4vS3RcdRPFhaVXIsP6qxQLFsl1 D+5EPyTSGB+h+NuTHB3tQSNQ1PIPj+JgIeTRgOWgKUiWspWGGJ6b5Anndy83jn8FAmCd NvEKs/Zs1YHrx54fAVjuad++OW9MaruUEQKdQGrV0RpHDnbx7NjNZ0uHDJiP4h3m/uGe 68bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="d5Y/AYoG"; 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 o15si2448603pja.139.2021.09.28.01.59.21; Tue, 28 Sep 2021 01:59:21 -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="d5Y/AYoG"; 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 S239788AbhI1JA4 (ORCPT + 8 others); Tue, 28 Sep 2021 05:00:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:42774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239784AbhI1JAq (ORCPT ); Tue, 28 Sep 2021 05:00:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DCD7861159; Tue, 28 Sep 2021 08:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632819546; bh=en7nVuj1sD+c8w9l7DbdzPI52yWs3ggAogVXkWmvTkg=; h=From:To:Cc:Subject:Date:From; b=d5Y/AYoGL1EaP0pg+ceT4RUNJ6EK7jtDoYxjgnhzt1s1haQvBmUFKmLUNs/8AfkRK dI00AA5kV7G74I0l7974dEAxLE5ol/gE9OO2Ox2OLoFtqlpREQ2JOy3PCoEtHfG7Gq S8rchhmS181CHTO6dyb+z3QmIGYI7NgbU6HPfDR+PrNqaAhUvi4ps+gQHpX2Bp5egS 7ZL5iKUdeE2iS+QTNXZ4e7MplHs5bdaRCl5Z8r3lKfnNasXnPOtfBpslyGuu7nYq3F WNYUMp9buu7u25bl/QLf6CrIsgb9ZLllwtICTdu2Cl/P55r6wUzlxA8UqQtPrqrnTo J9HTLrrXn5APw== From: Arnd Bergmann To: Yisen Zhuang , Salil Mehta , "David S. Miller" , Jakub Kicinski Cc: Arnd Bergmann , Guangbin Huang , Yufeng Mo , Jiaran Zhang , Jian Shen , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] net: hns3: fix hclge_dbg_dump_tm_pg() stack usage Date: Tue, 28 Sep 2021 10:58:34 +0200 Message-Id: <20210928085900.2394697-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 --- Changes in v2: - rearrange local variable as suggested by huangguangbin --- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 28 ++++++++++++++++--- 1 file changed, 24 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..32f62cd2dd99 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,24 @@ 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) +{ + char *data_str; + int ret; + + 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;