Commit 5982b47a authored by Yogesh Ashok Powar's avatar Yogesh Ashok Powar Committed by John W. Linville

mwifiex: replace kmalloc & memcpy sequence with kmemdup

Sequence of kmalloc/kzalloc and memcpy is replaced with
kmemdup.

Cc: Walter Harms <wharms@bfs.de>
Signed-off-by: default avatarYogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: default avatarKiran Divekar <dkiran@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3459731a
...@@ -147,13 +147,12 @@ static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1, ...@@ -147,13 +147,12 @@ static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1,
u8 *ptr = rate1, *tmp; u8 *ptr = rate1, *tmp;
u32 i, j; u32 i, j;
tmp = kmalloc(rate1_size, GFP_KERNEL); tmp = kmemdup(rate1, rate1_size, GFP_KERNEL);
if (!tmp) { if (!tmp) {
dev_err(priv->adapter->dev, "failed to alloc tmp buf\n"); dev_err(priv->adapter->dev, "failed to alloc tmp buf\n");
return -ENOMEM; return -ENOMEM;
} }
memcpy(tmp, rate1, rate1_size);
memset(rate1, 0, rate1_size); memset(rate1, 0, rate1_size);
for (i = 0; rate2[i] && i < rate2_size; i++) { for (i = 0; rate2[i] && i < rate2_size; i++) {
......
...@@ -1479,12 +1479,12 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, ...@@ -1479,12 +1479,12 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv,
dev_err(priv->adapter->dev, " failed to alloc bss_desc\n"); dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
return -ENOMEM; return -ENOMEM;
} }
beacon_ie = kzalloc(ie_len, GFP_KERNEL);
beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL);
if (!beacon_ie) { if (!beacon_ie) {
dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n"); dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
return -ENOMEM; return -ENOMEM;
} }
memcpy(beacon_ie, ie_buf, ie_len);
ret = mwifiex_fill_new_bss_desc(priv, bssid, rssi, beacon_ie, ret = mwifiex_fill_new_bss_desc(priv, bssid, rssi, beacon_ie,
ie_len, beacon_period, ie_len, beacon_period,
...@@ -1986,7 +1986,7 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv) ...@@ -1986,7 +1986,7 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv)
priv->curr_bcn_size = curr_bss->beacon_buf_size; priv->curr_bcn_size = curr_bss->beacon_buf_size;
kfree(priv->curr_bcn_buf); kfree(priv->curr_bcn_buf);
priv->curr_bcn_buf = kzalloc(curr_bss->beacon_buf_size, priv->curr_bcn_buf = kmalloc(curr_bss->beacon_buf_size,
GFP_KERNEL); GFP_KERNEL);
if (!priv->curr_bcn_buf) { if (!priv->curr_bcn_buf) {
dev_err(priv->adapter->dev, dev_err(priv->adapter->dev,
......
...@@ -199,13 +199,14 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ...@@ -199,13 +199,14 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
dev_err(priv->adapter->dev, " failed to alloc bss_desc\n"); dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
return -ENOMEM; return -ENOMEM;
} }
beacon_ie = kzalloc(bss->len_beacon_ies, GFP_KERNEL);
beacon_ie = kmemdup(bss->information_elements,
bss->len_beacon_ies, GFP_KERNEL);
if (!beacon_ie) { if (!beacon_ie) {
dev_err(priv->adapter->dev, " failed to alloc bss_desc\n"); dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
return -ENOMEM; return -ENOMEM;
} }
memcpy(beacon_ie, bss->information_elements,
bss->len_beacon_ies);
ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal, ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal,
beacon_ie, bss->len_beacon_ies, beacon_ie, bss->len_beacon_ies,
bss->beacon_interval, bss->beacon_interval,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment