Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: wilc1000: use kzalloc_flex

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>
Link: https://patch.msgid.link/20260327030616.8774-1-rosenp@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Rosen Penev and committed by
Johannes Berg
d278bf86 49152949

+4 -4
+4 -4
drivers/net/wireless/microchip/wilc1000/hif.c
··· 1123 1123 wid_list[0].size = sizeof(char); 1124 1124 wid_list[0].val = (s8 *)&cipher_mode; 1125 1125 1126 - key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1126 + key_buf = kzalloc_flex(*key_buf, key, t_key_len); 1127 1127 if (!key_buf) 1128 1128 return -ENOMEM; 1129 1129 ··· 1151 1151 struct wid wid; 1152 1152 struct wilc_sta_wpa_ptk *key_buf; 1153 1153 1154 - key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1154 + key_buf = kzalloc_flex(*key_buf, key, t_key_len); 1155 1155 if (!key_buf) 1156 1156 return -ENOMEM; 1157 1157 ··· 1186 1186 struct wid wid; 1187 1187 struct wilc_wpa_igtk *key_buf; 1188 1188 1189 - key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1189 + key_buf = kzalloc_flex(*key_buf, key, t_key_len); 1190 1190 if (!key_buf) 1191 1191 return -ENOMEM; 1192 1192 ··· 1217 1217 struct wilc_gtk_key *gtk_key; 1218 1218 int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; 1219 1219 1220 - gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); 1220 + gtk_key = kzalloc_flex(*gtk_key, key, t_key_len); 1221 1221 if (!gtk_key) 1222 1222 return -ENOMEM; 1223 1223