Search Linux Wireless

[PATCH 2/2] wifi: cfg80211: avoid strlen() in cfg80211_michael_mic_failure()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since 'sprintf()' returns the number of characters emitted, an extra
call to 'strlen()' in 'cfg80211_michael_mic_failure()' may be dropped.

Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
---
 net/wireless/mlme.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 775cac4d6100..c6adaf835abd 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -239,12 +239,11 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
 	char *buf = kmalloc(128, gfp);
 
 	if (buf) {
-		sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
-			"keyid=%d %scast addr=%pM)", key_id,
+		memset(&wrqu, 0, sizeof(wrqu));
+		wrqu.data.length = sprintf(buf, "MLME-MICHAELMICFAILURE."
+			"indication(keyid=%d %scast addr=%pM)", key_id,
 			key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
 			addr);
-		memset(&wrqu, 0, sizeof(wrqu));
-		wrqu.data.length = strlen(buf);
 		wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
 		kfree(buf);
 	}
-- 
2.41.0




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux