diff mbox series

[5/5] util: warn on invalid channels when iterating a frequency set

Message ID 20241024164635.176631-5-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/5] band: correct oper class 136 starting frequency | expand

Checks

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

Commit Message

James Prestwood Oct. 24, 2024, 4:46 p.m. UTC
This should not happen but if it does we should alert the user.
---
 src/util.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/src/util.c b/src/util.c
index 5ce764ae..8c690fc0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -464,6 +464,11 @@  static void scan_channels_foreach(uint32_t channel, void *user_data)
 	uint32_t freq;
 
 	freq = band_channel_to_freq(channel, channels_data->band);
+	if (!freq) {
+		l_warn("invalid channel %u for band %u", channel,
+			channels_data->band);
+		return;
+	}
 
 	channels_data->func(freq, channels_data->user_data);
 }