From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Johannes Berg <johannes.berg@intel.com>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-wireless@vger.kernel.org
Cc: Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Johannes Berg <johannes@sipsolutions.net>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/2] wifi: nl80211: Call size_add() only once
Date: Wed, 17 Jun 2026 13:12:37 +0200 [thread overview]
Message-ID: <20260617112250.2791461-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20260617112250.2791461-1-andriy.shevchenko@linux.intel.com>
Since size_add() may take a few arguments at once, call it only once.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
net/wireless/nl80211.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 53b4b3f76697..98f92c268944 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -11560,13 +11560,10 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
attrs[NL80211_ATTR_SCHED_SCAN_RSSI_ADJUST]))
return ERR_PTR(-EINVAL);
- size = struct_size(request, channels, n_channels);
- size = size_add(size, array_size(sizeof(*request->ssids), n_ssids));
- size = size_add(size, array_size(sizeof(*request->match_sets),
- n_match_sets));
- size = size_add(size, array_size(sizeof(*request->scan_plans),
- n_plans));
- size = size_add(size, ie_len);
+ size = size_add(struct_size(request, channels, n_channels), ie_len,
+ array_size(sizeof(*request->ssids), n_ssids),
+ array_size(sizeof(*request->match_sets), n_match_sets),
+ array_size(sizeof(*request->scan_plans), n_plans));
request = kzalloc(size, GFP_KERNEL);
if (!request)
return ERR_PTR(-ENOMEM);
--
2.50.1
prev parent reply other threads:[~2026-06-17 11:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 11:12 [rfc, PATCH v1 0/2] overflow: Convert size_add() to take variadic arguments Andy Shevchenko
2026-06-17 11:12 ` [PATCH v1 1/2] overflow: Allow to sum a few arguments at once Andy Shevchenko
2026-06-17 12:56 ` Johannes Berg
2026-06-17 11:12 ` Andy Shevchenko [this message]
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=20260617112250.2791461-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gustavoars@kernel.org \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
/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