From: Arnd Bergmann <arnd@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Mark Bloch <mbloch@nvidia.com>, Tariq Toukan <tariqt@nvidia.com>,
Carolina Jubran <cjubran@nvidia.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Simon Horman <horms@kernel.org>,
Cosmin Ratiu <cratiu@nvidia.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] [v2] devlink: move DEVLINK_ATTR_MAX-sized array off stack
Date: Wed, 9 Jul 2025 16:59:00 +0200 [thread overview]
Message-ID: <20250709145908.259213-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
There are many possible devlink attributes, so having an array of them
on the stack can cause a warning for excessive stack usage:
net/devlink/rate.c: In function 'devlink_nl_rate_tc_bw_parse':
net/devlink/rate.c:382:1: error: the frame size of 1648 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
Change this to dynamic allocation instead.
Fixes: 566e8f108fc7 ("devlink: Extend devlink rate API with traffic classes bandwidth management")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I see that only two of the many array entries are actually used in this
function: DEVLINK_ATTR_RATE_TC_INDEX and DEVLINK_ATTR_RATE_TC_BW. If there
is an interface to extract just a single entry, using that would be
a little easier than the kcalloc().
v2: use __free() helper to simplify cleanup
---
net/devlink/rate.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/devlink/rate.c b/net/devlink/rate.c
index d39300a9b3d4..3c4689c6cefb 100644
--- a/net/devlink/rate.c
+++ b/net/devlink/rate.c
@@ -346,10 +346,14 @@ static int devlink_nl_rate_tc_bw_parse(struct nlattr *parent_nest, u32 *tc_bw,
unsigned long *bitmap,
struct netlink_ext_ack *extack)
{
- struct nlattr *tb[DEVLINK_ATTR_MAX + 1];
+ struct nlattr **tb __free(kfree) = NULL;
u8 tc_index;
int err;
+ tb = kcalloc(DEVLINK_ATTR_MAX + 1, sizeof(struct nlattr *), GFP_KERNEL);
+ if (!tb)
+ return -ENOMEM;
+
err = nla_parse_nested(tb, DEVLINK_ATTR_MAX, parent_nest,
devlink_dl_rate_tc_bws_nl_policy, extack);
if (err)
--
2.39.5
next reply other threads:[~2025-07-09 14:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-09 14:59 Arnd Bergmann [this message]
2025-07-10 0:45 ` Jakub Kicinski
2025-07-10 7:58 ` Carolina Jubran
2025-07-13 12:28 ` Carolina Jubran
2025-07-14 15:27 ` Jakub Kicinski
2025-07-14 18:29 ` Carolina Jubran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250709145908.259213-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®