Skip to content

Commit 1cd8909

Browse files
jerome-pouillergregkh
authored andcommitted
staging: wfx: improve error handling of hif_join()
Smatch complains: hif_tx.c:319 hif_join() error: we previously assumed 'channel' could be null (see line 315) 311 if (!hif) 312 return -ENOMEM; 313 body->infrastructure_bss_mode = !conf->ibss_joined; 314 body->short_preamble = conf->use_short_preamble; 315 if (channel && channel->flags & IEEE80211_CHAN_NO_IR) ^^^^^^^ 316 body->probe_for_join = 0; 317 else 318 body->probe_for_join = 1; 319 body->channel_number = channel->hw_value; ^^^^^^^^^^^^^^^^^ 320 body->beacon_interval = cpu_to_le32(conf->beacon_int); 321 body->basic_rate_set = Indeed, channel can't be NULL (else I would have seen plenty of Ooops this past year). This patch explicitly claims this restriction. Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Jérôme Pouiller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0110ce6 commit 1cd8909

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/staging/wfx/hif_tx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,13 @@ int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf,
308308
WARN_ON(!conf->basic_rates);
309309
WARN_ON(sizeof(body->ssid) < ssidlen);
310310
WARN(!conf->ibss_joined && !ssidlen, "joining an unknown BSS");
311+
if (WARN_ON(!channel))
312+
return -EINVAL;
311313
if (!hif)
312314
return -ENOMEM;
313315
body->infrastructure_bss_mode = !conf->ibss_joined;
314316
body->short_preamble = conf->use_short_preamble;
315-
if (channel && channel->flags & IEEE80211_CHAN_NO_IR)
317+
if (channel->flags & IEEE80211_CHAN_NO_IR)
316318
body->probe_for_join = 0;
317319
else
318320
body->probe_for_join = 1;

0 commit comments

Comments
 (0)