summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/quantenna
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/net/wireless/quantenna
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/net/wireless/quantenna')
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/commands.c23
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/core.c2
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/event.c2
-rw-r--r--drivers/net/wireless/quantenna/qtnfmac/util.c2
4 files changed, 14 insertions, 15 deletions
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c
index 956c5763662f..b1908fa90cfa 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/commands.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c
@@ -981,7 +981,7 @@ qtnf_parse_wowlan_info(struct qtnf_wmac *mac,
const struct qlink_wowlan_support *data1;
struct wiphy_wowlan_support *supp;
- supp = kzalloc(sizeof(*supp), GFP_KERNEL);
+ supp = kzalloc_obj(*supp, GFP_KERNEL);
if (!supp)
return;
@@ -1031,8 +1031,8 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
if (WARN_ON(resp->n_reg_rules > NL80211_MAX_SUPP_REG_RULES))
return -E2BIG;
- mac->rd = kzalloc(struct_size(mac->rd, reg_rules, resp->n_reg_rules),
- GFP_KERNEL);
+ mac->rd = kzalloc_flex(*mac->rd, reg_rules, resp->n_reg_rules,
+ GFP_KERNEL);
if (!mac->rd)
return -ENOMEM;
@@ -1084,8 +1084,8 @@ qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
return -EINVAL;
}
- limits = kcalloc(rec->n_limits, sizeof(*limits),
- GFP_KERNEL);
+ limits = kzalloc_objs(*limits, rec->n_limits,
+ GFP_KERNEL);
if (!limits)
return -ENOMEM;
@@ -1254,9 +1254,8 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac,
sizeof(mac_info->vht_cap_mod_mask));
mac_info->n_if_comb = resp_info->n_iface_combinations;
- mac_info->if_comb = kcalloc(mac->macinfo.n_if_comb,
- sizeof(*mac->macinfo.if_comb),
- GFP_KERNEL);
+ mac_info->if_comb = kzalloc_objs(*mac->macinfo.if_comb,
+ mac->macinfo.n_if_comb, GFP_KERNEL);
if (!mac->macinfo.if_comb)
return -ENOMEM;
@@ -1341,8 +1340,8 @@ static int qtnf_cmd_band_fill_iftype(const u8 *data,
if (band->n_iftype_data == 0)
return 0;
- iftype_data = kcalloc(band->n_iftype_data, sizeof(*iftype_data),
- GFP_KERNEL);
+ iftype_data = kzalloc_objs(*iftype_data, band->n_iftype_data,
+ GFP_KERNEL);
if (!iftype_data) {
band->n_iftype_data = 0;
return -ENOMEM;
@@ -1389,8 +1388,8 @@ qtnf_cmd_resp_fill_band_info(struct ieee80211_supported_band *band,
return 0;
if (!band->channels)
- band->channels = kcalloc(band->n_channels, sizeof(*chan),
- GFP_KERNEL);
+ band->channels = kzalloc_objs(*chan, band->n_channels,
+ GFP_KERNEL);
if (!band->channels) {
band->n_channels = 0;
return -ENOMEM;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c
index 38af6cdc2843..4cab8dee332b 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/core.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/core.c
@@ -212,7 +212,7 @@ static int qtnf_mac_init_single_band(struct wiphy *wiphy,
{
int ret;
- wiphy->bands[band] = kzalloc(sizeof(*wiphy->bands[band]), GFP_KERNEL);
+ wiphy->bands[band] = kzalloc_obj(*wiphy->bands[band], GFP_KERNEL);
if (!wiphy->bands[band])
return -ENOMEM;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/event.c b/drivers/net/wireless/quantenna/qtnfmac/event.c
index 71840f41b73c..c16cd1e5286a 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/event.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/event.c
@@ -41,7 +41,7 @@ qtnf_event_handle_sta_assoc(struct qtnf_wmac *mac, struct qtnf_vif *vif,
return -EPROTO;
}
- sinfo = kzalloc(sizeof(*sinfo), GFP_KERNEL);
+ sinfo = kzalloc_obj(*sinfo, GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
diff --git a/drivers/net/wireless/quantenna/qtnfmac/util.c b/drivers/net/wireless/quantenna/qtnfmac/util.c
index cda6f5f3f38a..5c1a5a8f87a6 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/util.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/util.c
@@ -59,7 +59,7 @@ struct qtnf_sta_node *qtnf_sta_list_add(struct qtnf_vif *vif,
if (node)
goto done;
- node = kzalloc(sizeof(*node), GFP_KERNEL);
+ node = kzalloc_obj(*node, GFP_KERNEL);
if (unlikely(!node))
goto done;