staging: rtl8192u: Use kmalloc_array instead of kmalloc
PATCH v4 1/1 staging: rtl8192u: Use kmalloc_array instead of kmalloc
Use kmalloc_array instead of kmalloc for arrays. The Coccinelle patch for this conversion is:
@@
type T;
expression F;
constant FLAG;
@@
- kmalloc(sizeof(T)*F, FLAG)
+ kmalloc_array(F, sizeof(T), FLAG)
---
Changes since v3:
* Changed RECORDER_WIN_SIZE to REORDER_WIN_SIZE as the former was incorrect.
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2 -2
@@ -601,8 +601,8 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,bool bMatchWinStart = false, bPktInBuf = false;IEEE80211_DEBUG (IEEE80211_DL_REORDER ,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n" ,__func__,SeqNum,pTS->RxIndicateSeq,WinSize); - prxbIndicateArray =kmalloc (sizeof (struct ieee80211_rxb *) * -REORDER_WIN_SIZE ,GFP_KERNEL ); + prxbIndicateArray =kmalloc_array (REORDER_WIN_SIZE , +sizeof (struct ieee80211_rxb *),GFP_KERNEL );if (!prxbIndicateArray)return ;
Signature · 1 line
2.5.0
Greg KH
maintainerQuoted 26 lines · Janani Ravichandran
Use
kmalloc_arrayinstead of kmalloc for arrays. The Coccinelle patch for this conversion is:@@
type T;
expression F;
constant FLAG;
@@-
kmalloc(sizeof(T)*F, FLAG)
+kmalloc_array(F, sizeof(T), FLAG)Signed-off-by Janani Ravichandran <[email protected]>---
Changes since v3:
* ChangedRECORDER_WIN_SIZEtoREORDER_WIN_SIZEas the former was incorrect.drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +0
-0
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c static void RxReorderIndicatePacket(struct ieee80211_device *ieee, · line 605
Quoted 7 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2
-2@@ -601,8 +601,8 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,bool bMatchWinStart = false, bPktInBuf = false;IEEE80211_DEBUG (IEEE80211_DL_REORDER ,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n" ,__func__,SeqNum,pTS->RxIndicateSeq,WinSize); - prxbIndicateArray =kmalloc (sizeof (struct ieee80211_rxb *) * -REORDER_WIN_SIZE ,GFP_KERNEL ); + prxbIndicateArray =kmalloc_array (REORDER_WIN_SIZE , +sizeof (struct ieee80211_rxb *),GFP_KERNEL );
For "static" allocations like this, where we know the size at compile time, it doesn't make any sense to call kmalloc_array(), in fact, it just adds complexity.
sorry,
greg k-h