diff mbox series

[2/2] netdev: check iftype in channel switch event

Message ID 20230223181417.1384624-2-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/2] monitor: print contents of beacon head/tail, and probe attributes | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Feb. 23, 2023, 6:14 p.m. UTC
Some drivers send this event when starting AP mode which means
the handshake object is NULL, causing a crash.
---
 src/netdev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/netdev.c b/src/netdev.c
index 035dbd00..dbfdff1a 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -5145,8 +5145,12 @@  static void netdev_send_sa_query_delay(struct l_timeout *timeout,
 static void netdev_channel_switch_event(struct l_genl_msg *msg,
 					struct netdev *netdev)
 {
-	_auto_(l_free) struct band_chandef *chandef =
-						l_new(struct band_chandef, 1);
+	_auto_(l_free) struct band_chandef *chandef = NULL;
+
+	if (netdev->type != NL80211_IFTYPE_STATION)
+		return;
+
+	chandef = l_new(struct band_chandef, 1);
 
 	if (nl80211_parse_chandef(msg, chandef) < 0) {
 		l_debug("Couldn't parse operating channel info.");