diff mbox series

wifi: wireless: avoid strlen() in cfg80211_michael_mic_failure()

Message ID 20240110054246.371651-1-dmantipov@yandex.ru
State New
Headers show
Series wifi: wireless: avoid strlen() in cfg80211_michael_mic_failure() | expand

Commit Message

Dmitry Antipov Jan. 10, 2024, 5:42 a.m. UTC
In 'cfg80211_michael_mic_failure()', avoid extra call to 'strlen()'
by using the value returned by 'sprintf()'. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 net/wireless/mlme.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index f635a8b6ca2e..43ba7891e2a3 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -241,12 +241,12 @@  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,
-			key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
-			addr);
 		memset(&wrqu, 0, sizeof(wrqu));
-		wrqu.data.length = strlen(buf);
+		wrqu.data.length =
+			sprintf(buf, "MLME-MICHAELMICFAILURE."
+				"indication(keyid=%d %scast addr=%pM)",
+				key_id, key_type == NL80211_KEYTYPE_GROUP
+				? "broad" : "uni", addr);
 		wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
 		kfree(buf);
 	}