From: Rosen Penev <rosenp@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Ajay Singh <ajay.kathat@microchip.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH wireless-next] wifi: wilc1000: use kzalloc_flex
Date: Thu, 26 Mar 2026 20:06:16 -0700 [thread overview]
Message-ID: <20260327030616.8774-1-rosenp@gmail.com> (raw)
Because key is a flexible array member, kzalloc_flex can be used to
handle the math properly and simplify the code slightly.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/wireless/microchip/wilc1000/hif.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c
index 944b2a812b63..009c4770a6f9 100644
--- a/drivers/net/wireless/microchip/wilc1000/hif.c
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -1123,7 +1123,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
wid_list[0].size = sizeof(char);
wid_list[0].val = (s8 *)&cipher_mode;
- key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL);
+ key_buf = kzalloc_flex(*key_buf, key, t_key_len);
if (!key_buf)
return -ENOMEM;
@@ -1151,7 +1151,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
struct wid wid;
struct wilc_sta_wpa_ptk *key_buf;
- key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL);
+ key_buf = kzalloc_flex(*key_buf, key, t_key_len);
if (!key_buf)
return -ENOMEM;
@@ -1186,7 +1186,7 @@ int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
struct wid wid;
struct wilc_wpa_igtk *key_buf;
- key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL);
+ key_buf = kzalloc_flex(*key_buf, key, t_key_len);
if (!key_buf)
return -ENOMEM;
@@ -1217,7 +1217,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
struct wilc_gtk_key *gtk_key;
int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN;
- gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL);
+ gtk_key = kzalloc_flex(*gtk_key, key, t_key_len);
if (!gtk_key)
return -ENOMEM;
--
2.53.0
reply other threads:[~2026-03-27 3:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260327030616.8774-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=ajay.kathat@microchip.com \
--cc=claudiu.beznea@tuxon.dev \
--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