Skip to contentSkip to conversation

staging/rtl8192u/ieee80211: replace kmalloc with kzalloc

PATCH Superseded Elena Afanasova 2 participants 2 messages Oct 23, 2020 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging/rtl8192u/ieee80211: replace kmalloc with kzalloc

kmalloc() and memset() calls can be replaced with kzalloc(). Found with Coccinelle.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +1 -4
index 63a561ab4a76..fb8483c499b3 100644
@@ -227,13 +227,10 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
 {
 	struct ieee80211_txb *txb;
 	int i;
-	txb = kmalloc(
-		sizeof(struct ieee80211_txb) + (sizeof(u8 *) * nr_frags),
-		gfp_mask);
+	txb = kzalloc(sizeof(*txb) + (sizeof(u8 *) * nr_frags), gfp_mask);
 	if (!txb)
 		return NULL;
 
-	memset(txb, 0, sizeof(struct ieee80211_txb));
 	txb->nr_frags = nr_frags;
 	txb->frag_size = __cpu_to_le16(txb_size);
 
Signature · 1 line
2.25.1
#1 lore raw

The above is not the right subject line for this file (ie the part to the left of the colon). You should use git log --oneline on this file to see what others have done.

julia

Quoted 35 lines · Elena Afanasova

kmalloc() and memset() calls can be replaced with kzalloc(). Found with Coccinelle.

---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +1 -5
index 63a561ab4a76..fb8483c499b3 100644
@@ -227,13 +227,10 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
 {
 	struct ieee80211_txb *txb;
 	int i;
-	txb = kmalloc(
-		sizeof(struct ieee80211_txb) + (sizeof(u8 *) * nr_frags),
-		gfp_mask);
+	txb = kzalloc(sizeof(*txb) + (sizeof(u8 *) * nr_frags), gfp_mask);
 	if (!txb)
 		return NULL;
 
-	memset(txb, 0, sizeof(struct ieee80211_txb));
 	txb->nr_frags = nr_frags;
 	txb->frag_size = __cpu_to_le16(txb_size);
 
--

2.25.1

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20201023100507.4569-1-eafanasova%40gmail.com.