All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mwifiex: replace kmalloc & memcpy sequences with kmemdup
@ 2011-08-25  3:52 Bing Zhao
  2011-08-25  4:19 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Zhao @ 2011-08-25  3:52 UTC (permalink / raw)
  To: linux-wireless
  Cc: John W. Linville, Amitkumar Karwar, Kiran Divekar, Yogesh Powar,
	Frank Huang, Bing Zhao, Walter Harms

From: Yogesh Ashok Powar <yogeshp@marvell.com>

Sequences of kmalloc/kzalloc and memcpy are replaced with
kmemdups.

Cc: Walter Harms <wharms@bfs.de>
Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: Kiran Divekar <dkiran@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
 drivers/net/wireless/mwifiex/join.c      |    5 ++---
 drivers/net/wireless/mwifiex/scan.c      |   17 ++++++++++-------
 drivers/net/wireless/mwifiex/sta_ioctl.c |    9 +++++----
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
index 5cdad92..303858e 100644
--- a/drivers/net/wireless/mwifiex/join.c
+++ b/drivers/net/wireless/mwifiex/join.c
@@ -147,13 +147,12 @@ static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1,
 	u8 *ptr = rate1, *tmp;
 	u32 i, j;
 
-	tmp = kmalloc(rate1_size, GFP_KERNEL);
+	tmp = kmemdup(rate1, rate1_size, GFP_KERNEL);
 	if (!tmp) {
-		dev_err(priv->adapter->dev, "failed to alloc tmp buf\n");
+		dev_err(priv->adapter->dev, "failed to duplicate rate buf\n");
 		return -ENOMEM;
 	}
 
-	memcpy(tmp, rate1, rate1_size);
 	memset(rate1, 0, rate1_size);
 
 	for (i = 0; rate2[i] && i < rate2_size; i++) {
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 37ca2f9..84cb059 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -1479,12 +1479,12 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv,
 		dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
 		return -ENOMEM;
 	}
-	beacon_ie = kzalloc(ie_len, GFP_KERNEL);
+
+	beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL);
 	if (!beacon_ie) {
-		dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
+		dev_err(priv->adapter->dev, " failed to duplicate beacon_ie\n");
 		return -ENOMEM;
 	}
-	memcpy(beacon_ie, ie_buf, ie_len);
 
 	ret = mwifiex_fill_new_bss_desc(priv, bssid, rssi, beacon_ie,
 					ie_len, beacon_period,
@@ -1986,17 +1986,20 @@ mwifiex_save_curr_bcn(struct mwifiex_private *priv)
 		priv->curr_bcn_size = curr_bss->beacon_buf_size;
 
 		kfree(priv->curr_bcn_buf);
-		priv->curr_bcn_buf = kzalloc(curr_bss->beacon_buf_size,
+
+		priv->curr_bcn_buf = kmemdup(curr_bss->beacon_buf,
+						curr_bss->beacon_buf_size,
 						GFP_KERNEL);
 		if (!priv->curr_bcn_buf) {
 			dev_err(priv->adapter->dev,
-					"failed to alloc curr_bcn_buf\n");
+					"failed to mem dup curr_bcn_buf\n");
 			return;
 		}
+	} else {
+		memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
+			curr_bss->beacon_buf_size);
 	}
 
-	memcpy(priv->curr_bcn_buf, curr_bss->beacon_buf,
-		curr_bss->beacon_buf_size);
 	dev_dbg(priv->adapter->dev, "info: current beacon saved %d\n",
 		priv->curr_bcn_size);
 
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index 3fca219..16b2363 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -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");
 			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) {
-			dev_err(priv->adapter->dev, " failed to alloc bss_desc\n");
+			dev_err(priv->adapter->dev, "failed to memdup IEs\n");
 			return -ENOMEM;
 		}
-		memcpy(beacon_ie, bss->information_elements,
-		       bss->len_beacon_ies);
+
 		ret = mwifiex_fill_new_bss_desc(priv, bss->bssid, bss->signal,
 						beacon_ie, bss->len_beacon_ies,
 						bss->beacon_interval,
-- 
1.7.0.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mwifiex: replace kmalloc & memcpy sequences with kmemdup
  2011-08-25  3:52 [PATCH] mwifiex: replace kmalloc & memcpy sequences with kmemdup Bing Zhao
@ 2011-08-25  4:19 ` Joe Perches
  2011-08-25 19:39   ` Bing Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2011-08-25  4:19 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Kiran Divekar, Yogesh Powar, Frank Huang, Walter Harms

On Wed, 2011-08-24 at 20:52 -0700, Bing Zhao wrote:
> Sequences of kmalloc/kzalloc and memcpy are replaced with
> kmemdups.
> diff --git a/drivers/net/wireless/mwifiex/join.c b/drivers/net/wireless/mwifiex/join.c
[]
> -	tmp = kmalloc(rate1_size, GFP_KERNEL);
> +	tmp = kmemdup(rate1, rate1_size, GFP_KERNEL);
>  	if (!tmp) {
> -		dev_err(priv->adapter->dev, "failed to alloc tmp buf\n");
> +		dev_err(priv->adapter->dev, "failed to duplicate rate buf\n");

I wouldn't modify any OOM message.
These _are_ allocs failures.

[all the others removed]


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] mwifiex: replace kmalloc & memcpy sequences with kmemdup
  2011-08-25  4:19 ` Joe Perches
@ 2011-08-25 19:39   ` Bing Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Bing Zhao @ 2011-08-25 19:39 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-wireless, John W. Linville, Amitkumar Karwar,
	Kiran Divekar, Yogesh Powar, Frank Huang, Walter Harms

SGkgSm9lLA0KDQpUaGFua3MgZm9yIHlvdXIgY29tbWVudC4NCg0KPiBTdWJqZWN0OiBSZTogW1BB
VENIXSBtd2lmaWV4OiByZXBsYWNlIGttYWxsb2MgJiBtZW1jcHkgc2VxdWVuY2VzIHdpdGgga21l
bWR1cA0KPiANCj4gT24gV2VkLCAyMDExLTA4LTI0IGF0IDIwOjUyIC0wNzAwLCBCaW5nIFpoYW8g
d3JvdGU6DQo+ID4gU2VxdWVuY2VzIG9mIGttYWxsb2Mva3phbGxvYyBhbmQgbWVtY3B5IGFyZSBy
ZXBsYWNlZCB3aXRoDQo+ID4ga21lbWR1cHMuDQo+ID4gZGlmZiAtLWdpdCBhL2RyaXZlcnMvbmV0
L3dpcmVsZXNzL213aWZpZXgvam9pbi5jIGIvZHJpdmVycy9uZXQvd2lyZWxlc3MvbXdpZmlleC9q
b2luLmMNCj4gW10NCj4gPiAtCXRtcCA9IGttYWxsb2MocmF0ZTFfc2l6ZSwgR0ZQX0tFUk5FTCk7
DQo+ID4gKwl0bXAgPSBrbWVtZHVwKHJhdGUxLCByYXRlMV9zaXplLCBHRlBfS0VSTkVMKTsNCj4g
PiAgCWlmICghdG1wKSB7DQo+ID4gLQkJZGV2X2Vycihwcml2LT5hZGFwdGVyLT5kZXYsICJmYWls
ZWQgdG8gYWxsb2MgdG1wIGJ1ZlxuIik7DQo+ID4gKwkJZGV2X2Vycihwcml2LT5hZGFwdGVyLT5k
ZXYsICJmYWlsZWQgdG8gZHVwbGljYXRlIHJhdGUgYnVmXG4iKTsNCj4gDQo+IEkgd291bGRuJ3Qg
bW9kaWZ5IGFueSBPT00gbWVzc2FnZS4NCj4gVGhlc2UgX2FyZV8gYWxsb2NzIGZhaWx1cmVzLg0K
DQpWMiBwYXRjaCBoYXMgYmVlbiBzZW50Lg0KDQpUaGFua3MsDQpCaW5nDQoNCj4gDQo+IFthbGwg
dGhlIG90aGVycyByZW1vdmVkXQ0KDQo=

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-25 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25  3:52 [PATCH] mwifiex: replace kmalloc & memcpy sequences with kmemdup Bing Zhao
2011-08-25  4:19 ` Joe Perches
2011-08-25 19:39   ` Bing Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.