Skip to contentSkip to conversation

Change kmalloc to kmalloc_array and rearrange statement

PATCH In review Janani Ravichandran 2 participants 4 messages Feb 16, 2016 Staging

lore
Share & tools
lore
#0 lore raw

cover Change kmalloc to kmalloc_array and rearrange statement

This patchset changes a call to kmalloc to kmalloc_array and splits the statement across multiple lines to respect the 80 char per line limit.

Janani Ravichandran (2):
staging: wilc1000: Use kmalloc_array instead of kmalloc
staging: wilc1000: Rearrange statement to respect 80 char limit

 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/2 staging: wilc1000: Use kmalloc_array instead of kmalloc

Use kmalloc_array instead of kmalloc for arrays to prevent integer overflows.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -1
index 81a2ee9..7554cd4 100644
@@ -664,7 +664,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 		PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
 
 		if (request->n_ssids >= 1) {
-			strHiddenNetwork.net_info = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
+			strHiddenNetwork.net_info = kmalloc_array(request->n_ssids, sizeof(struct hidden_network), GFP_KERNEL);
 			strHiddenNetwork.n_ssids = request->n_ssids;
 
 
Signature · 1 line
2.5.0
#2 lore raw

Re: [Outreachy kernel] [PATCH 1/2] staging: wilc1000: Use kmalloc_array instead of kmalloc

Quoted 2 lines · Janani Ravichandran

Use kmalloc_array instead of kmalloc for arrays to prevent integer overflows.

I think it should have been v2, to indicat to Greg that the original patch was not useful.

julia

Quoted 29 lines
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +1 -2
index 81a2ee9..7554cd4 100644
@@ -664,7 +664,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 		PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
 
 		if (request->n_ssids >= 1) {
-			strHiddenNetwork.net_info = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL);
+			strHiddenNetwork.net_info = kmalloc_array(request->n_ssids, sizeof(struct hidden_network), GFP_KERNEL);
 			strHiddenNetwork.n_ssids = request->n_ssids;
 
 
--

2.5.0

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/351c2cb45bd6c3f0ac54246c66b693e204c172a8.1455661012.git.janani.rvchndrn%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw

PATCH 2/2 staging: wilc1000: Rearrange statement to respect 80 char limit

In reply to Janani Ravichandran

Split statement across multiple lines as the line modified is over 80 chars in length.

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +4 -1
index 7554cd4..eeb9843 100644
@@ -664,7 +664,10 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
 		PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
 
 		if (request->n_ssids >= 1) {
-			strHiddenNetwork.net_info = kmalloc_array(request->n_ssids, sizeof(struct hidden_network), GFP_KERNEL);
+			strHiddenNetwork.net_info =
+				kmalloc_array(request->n_ssids,
+					      sizeof(struct hidden_network),
+					      GFP_KERNEL);
 			strHiddenNetwork.n_ssids = request->n_ssids;
 
 
Signature · 1 line
2.5.0