treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This patch replaces cases of: kzalloc(a * b, gfp) with: kcalloc(a * b, gfp) as well as handling cases of: kzalloc(a * b * c, gfp) with: kzalloc(array3_size(a, b, c), gfp) as it's slightly less ugly than: kzalloc_array(array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: kzalloc(4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( kzalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kzalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kzalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(__u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(char) * COUNT + COUNT , ...) | kzalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kzalloc + kcalloc ( - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( kzalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( kzalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( kzalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( kzalloc(C1 * C2 * C3, ...) | kzalloc( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kzalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( kzalloc(sizeof(THING) * C2, ...) | kzalloc(sizeof(TYPE) * C2, ...) | kzalloc(C1 * C2 * C3, ...) | kzalloc(C1 * C2, ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - (E1) * E2 + E1, E2 , ...) | - kzalloc + kcalloc ( - (E1) * (E2) + E1, E2 , ...) | - kzalloc + kcalloc ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
@@ -582,7 +582,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt)
|
||||
}
|
||||
|
||||
htt->rx_ring.netbufs_ring =
|
||||
kzalloc(htt->rx_ring.size * sizeof(struct sk_buff *),
|
||||
kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *),
|
||||
GFP_KERNEL);
|
||||
if (!htt->rx_ring.netbufs_ring)
|
||||
goto err_netbuf;
|
||||
|
@@ -155,7 +155,7 @@ ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
|
||||
const void **tb;
|
||||
int ret;
|
||||
|
||||
tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
|
||||
tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp);
|
||||
if (!tb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
@@ -1041,7 +1041,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy,
|
||||
|
||||
n_channels = request->n_channels;
|
||||
|
||||
channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL);
|
||||
channels = kcalloc(n_channels, sizeof(u16), GFP_KERNEL);
|
||||
if (channels == NULL) {
|
||||
ath6kl_warn("failed to set scan channels, scan all channels");
|
||||
n_channels = 0;
|
||||
|
@@ -1958,7 +1958,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar)
|
||||
if (!bands)
|
||||
return -EINVAL;
|
||||
|
||||
ar->survey = kzalloc(sizeof(struct survey_info) * chans, GFP_KERNEL);
|
||||
ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL);
|
||||
if (!ar->survey)
|
||||
return -ENOMEM;
|
||||
ar->num_channels = chans;
|
||||
@@ -1988,8 +1988,9 @@ int carl9170_register(struct ar9170 *ar)
|
||||
if (WARN_ON(ar->mem_bitmap))
|
||||
return -EINVAL;
|
||||
|
||||
ar->mem_bitmap = kzalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG) *
|
||||
sizeof(unsigned long), GFP_KERNEL);
|
||||
ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG),
|
||||
sizeof(unsigned long),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!ar->mem_bitmap)
|
||||
return -ENOMEM;
|
||||
|
@@ -1518,7 +1518,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev,
|
||||
u16 i;
|
||||
u32 *data;
|
||||
|
||||
data = kzalloc(len * sizeof(u32), GFP_KERNEL);
|
||||
data = kcalloc(len, sizeof(u32), GFP_KERNEL);
|
||||
if (!data) {
|
||||
b43err(dev->wl, "allocation for samples loading failed\n");
|
||||
return -ENOMEM;
|
||||
|
@@ -3300,8 +3300,8 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
|
||||
|
||||
if ((phy->type == B43legacy_PHYTYPE_B) ||
|
||||
(phy->type == B43legacy_PHYTYPE_G)) {
|
||||
phy->_lo_pairs = kzalloc(sizeof(struct b43legacy_lopair)
|
||||
* B43legacy_LO_COUNT,
|
||||
phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT,
|
||||
sizeof(struct b43legacy_lopair),
|
||||
GFP_KERNEL);
|
||||
if (!phy->_lo_pairs)
|
||||
return -ENOMEM;
|
||||
|
@@ -1486,8 +1486,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr)
|
||||
(struct brcmf_commonring **)if_msgbuf->commonrings;
|
||||
msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings;
|
||||
msgbuf->max_flowrings = if_msgbuf->max_flowrings;
|
||||
msgbuf->flowring_dma_handle = kzalloc(msgbuf->max_flowrings *
|
||||
sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
|
||||
msgbuf->flowring_dma_handle =
|
||||
kcalloc(msgbuf->max_flowrings,
|
||||
sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
|
||||
if (!msgbuf->flowring_dma_handle)
|
||||
goto fail;
|
||||
|
||||
|
@@ -1058,7 +1058,7 @@ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel)
|
||||
channel_cnt = AF_PEER_SEARCH_CNT;
|
||||
else
|
||||
channel_cnt = SOCIAL_CHAN_CNT;
|
||||
default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list),
|
||||
default_chan_list = kcalloc(channel_cnt, sizeof(*default_chan_list),
|
||||
GFP_KERNEL);
|
||||
if (default_chan_list == NULL) {
|
||||
brcmf_err("channel list allocation failed\n");
|
||||
|
@@ -507,7 +507,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
|
||||
wlc->hw->wlc = wlc;
|
||||
|
||||
wlc->hw->bandstate[0] =
|
||||
kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC);
|
||||
kcalloc(MAXBANDS, sizeof(struct brcms_hw_band), GFP_ATOMIC);
|
||||
if (wlc->hw->bandstate[0] == NULL) {
|
||||
*err = 1006;
|
||||
goto fail;
|
||||
@@ -521,7 +521,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
|
||||
}
|
||||
|
||||
wlc->modulecb =
|
||||
kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC);
|
||||
kcalloc(BRCMS_MAXMODULES, sizeof(struct modulecb),
|
||||
GFP_ATOMIC);
|
||||
if (wlc->modulecb == NULL) {
|
||||
*err = 1009;
|
||||
goto fail;
|
||||
@@ -553,7 +554,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
|
||||
}
|
||||
|
||||
wlc->bandstate[0] =
|
||||
kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC);
|
||||
kcalloc(MAXBANDS, sizeof(struct brcms_band), GFP_ATOMIC);
|
||||
if (wlc->bandstate[0] == NULL) {
|
||||
*err = 1025;
|
||||
goto fail;
|
||||
|
@@ -922,7 +922,7 @@ il_init_channel_map(struct il_priv *il)
|
||||
D_EEPROM("Parsing data for %d channels.\n", il->channel_count);
|
||||
|
||||
il->channel_info =
|
||||
kzalloc(sizeof(struct il_channel_info) * il->channel_count,
|
||||
kcalloc(il->channel_count, sizeof(struct il_channel_info),
|
||||
GFP_KERNEL);
|
||||
if (!il->channel_info) {
|
||||
IL_ERR("Could not allocate channel_info\n");
|
||||
@@ -3041,9 +3041,9 @@ il_tx_queue_init(struct il_priv *il, u32 txq_id)
|
||||
}
|
||||
|
||||
txq->meta =
|
||||
kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL);
|
||||
kcalloc(actual_slots, sizeof(struct il_cmd_meta), GFP_KERNEL);
|
||||
txq->cmd =
|
||||
kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL);
|
||||
kcalloc(actual_slots, sizeof(struct il_device_cmd *), GFP_KERNEL);
|
||||
|
||||
if (!txq->meta || !txq->cmd)
|
||||
goto out_free_arrays;
|
||||
@@ -3455,7 +3455,7 @@ il_init_geos(struct il_priv *il)
|
||||
}
|
||||
|
||||
channels =
|
||||
kzalloc(sizeof(struct ieee80211_channel) * il->channel_count,
|
||||
kcalloc(il->channel_count, sizeof(struct ieee80211_channel),
|
||||
GFP_KERNEL);
|
||||
if (!channels)
|
||||
return -ENOMEM;
|
||||
@@ -4654,8 +4654,9 @@ il_alloc_txq_mem(struct il_priv *il)
|
||||
{
|
||||
if (!il->txq)
|
||||
il->txq =
|
||||
kzalloc(sizeof(struct il_tx_queue) *
|
||||
il->cfg->num_of_queues, GFP_KERNEL);
|
||||
kcalloc(il->cfg->num_of_queues,
|
||||
sizeof(struct il_tx_queue),
|
||||
GFP_KERNEL);
|
||||
if (!il->txq) {
|
||||
IL_ERR("Not enough memory for txq\n");
|
||||
return -ENOMEM;
|
||||
|
@@ -564,7 +564,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
|
||||
else
|
||||
blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN;
|
||||
|
||||
blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL);
|
||||
blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL);
|
||||
if (!blacklist)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -161,8 +161,9 @@ static int p54_generate_band(struct ieee80211_hw *dev,
|
||||
if (!tmp)
|
||||
goto err_out;
|
||||
|
||||
tmp->channels = kzalloc(sizeof(struct ieee80211_channel) *
|
||||
list->band_channel_num[band], GFP_KERNEL);
|
||||
tmp->channels = kcalloc(list->band_channel_num[band],
|
||||
sizeof(struct ieee80211_channel),
|
||||
GFP_KERNEL);
|
||||
if (!tmp->channels)
|
||||
goto err_out;
|
||||
|
||||
@@ -344,7 +345,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
|
||||
goto free;
|
||||
}
|
||||
priv->chan_num = max_channel_num;
|
||||
priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num,
|
||||
priv->survey = kcalloc(max_channel_num, sizeof(struct survey_info),
|
||||
GFP_KERNEL);
|
||||
if (!priv->survey) {
|
||||
ret = -ENOMEM;
|
||||
@@ -352,8 +353,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
|
||||
}
|
||||
|
||||
list->max_entries = max_channel_num;
|
||||
list->channels = kzalloc(sizeof(struct p54_channel_entry) *
|
||||
max_channel_num, GFP_KERNEL);
|
||||
list->channels = kcalloc(max_channel_num,
|
||||
sizeof(struct p54_channel_entry),
|
||||
GFP_KERNEL);
|
||||
if (!list->channels) {
|
||||
ret = -ENOMEM;
|
||||
goto free;
|
||||
|
@@ -244,7 +244,7 @@ mgt_init(islpci_private *priv)
|
||||
/* Alloc the cache */
|
||||
for (i = 0; i < OID_NUM_LAST; i++) {
|
||||
if (isl_oid[i].flags & OID_FLAG_CACHED) {
|
||||
priv->mib[i] = kzalloc(isl_oid[i].size *
|
||||
priv->mib[i] = kcalloc(isl_oid[i].size,
|
||||
(isl_oid[i].range + 1),
|
||||
GFP_KERNEL);
|
||||
if (!priv->mib[i])
|
||||
|
@@ -399,8 +399,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
|
||||
|
||||
new_node->win_size = win_size;
|
||||
|
||||
new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size,
|
||||
GFP_KERNEL);
|
||||
new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!new_node->rx_reorder_ptr) {
|
||||
kfree((u8 *) new_node);
|
||||
mwifiex_dbg(priv->adapter, ERROR,
|
||||
|
@@ -2106,15 +2106,16 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Allocate skb pointer buffers */
|
||||
card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) *
|
||||
card->mp_agg_pkt_limit, GFP_KERNEL);
|
||||
card->mpa_rx.skb_arr = kcalloc(card->mp_agg_pkt_limit, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!card->mpa_rx.skb_arr) {
|
||||
kfree(card->mp_regs);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) *
|
||||
card->mp_agg_pkt_limit, GFP_KERNEL);
|
||||
card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit,
|
||||
sizeof(*card->mpa_rx.len_arr),
|
||||
GFP_KERNEL);
|
||||
if (!card->mpa_rx.len_arr) {
|
||||
kfree(card->mp_regs);
|
||||
kfree(card->mpa_rx.skb_arr);
|
||||
|
@@ -1216,7 +1216,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
limits = kzalloc(sizeof(*limits) * rec->n_limits,
|
||||
limits = kcalloc(rec->n_limits, sizeof(*limits),
|
||||
GFP_KERNEL);
|
||||
if (!limits)
|
||||
return -ENOMEM;
|
||||
|
@@ -397,7 +397,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
|
||||
if (*offset)
|
||||
return 0;
|
||||
|
||||
data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL);
|
||||
data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -258,8 +258,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
|
||||
}
|
||||
|
||||
/* allocate memory for efuse_tbl and efuse_word */
|
||||
efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] *
|
||||
sizeof(u8), GFP_ATOMIC);
|
||||
efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE],
|
||||
GFP_ATOMIC);
|
||||
if (!efuse_tbl)
|
||||
return;
|
||||
efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
|
||||
|
@@ -1048,7 +1048,7 @@ int rtl_usb_probe(struct usb_interface *intf,
|
||||
}
|
||||
rtlpriv = hw->priv;
|
||||
rtlpriv->hw = hw;
|
||||
rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
|
||||
rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
if (!rtlpriv->usb_data)
|
||||
return -ENOMEM;
|
||||
|
@@ -154,7 +154,7 @@ int cw1200_queue_stats_init(struct cw1200_queue_stats *stats,
|
||||
spin_lock_init(&stats->lock);
|
||||
init_waitqueue_head(&stats->wait_link_id_empty);
|
||||
|
||||
stats->link_map_cache = kzalloc(sizeof(int) * map_capacity,
|
||||
stats->link_map_cache = kcalloc(map_capacity, sizeof(int),
|
||||
GFP_KERNEL);
|
||||
if (!stats->link_map_cache)
|
||||
return -ENOMEM;
|
||||
@@ -181,13 +181,13 @@ int cw1200_queue_init(struct cw1200_queue *queue,
|
||||
spin_lock_init(&queue->lock);
|
||||
timer_setup(&queue->gc, cw1200_queue_gc, 0);
|
||||
|
||||
queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity,
|
||||
GFP_KERNEL);
|
||||
queue->pool = kcalloc(capacity, sizeof(struct cw1200_queue_item),
|
||||
GFP_KERNEL);
|
||||
if (!queue->pool)
|
||||
return -ENOMEM;
|
||||
|
||||
queue->link_map_cache = kzalloc(sizeof(int) * stats->map_capacity,
|
||||
GFP_KERNEL);
|
||||
queue->link_map_cache = kcalloc(stats->map_capacity, sizeof(int),
|
||||
GFP_KERNEL);
|
||||
if (!queue->link_map_cache) {
|
||||
kfree(queue->pool);
|
||||
queue->pool = NULL;
|
||||
|
@@ -230,9 +230,9 @@ void cw1200_scan_work(struct work_struct *work)
|
||||
scan.type = WSM_SCAN_TYPE_BACKGROUND;
|
||||
scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND;
|
||||
}
|
||||
scan.ch = kzalloc(
|
||||
sizeof(struct wsm_scan_ch) * (it - priv->scan.curr),
|
||||
GFP_KERNEL);
|
||||
scan.ch = kcalloc(it - priv->scan.curr,
|
||||
sizeof(struct wsm_scan_ch),
|
||||
GFP_KERNEL);
|
||||
if (!scan.ch) {
|
||||
priv->scan.status = -ENOMEM;
|
||||
goto fail;
|
||||
|
Reference in New Issue
Block a user