Skip to content

Commit 4174c95

Browse files
MaochenWang1kartben
authored andcommitted
net: l2: wifi: add the check if dev is NULL
Add the check if dev is NULL (when iface is NULL, dev is NULL) when setting Wi-Fi CMD, in case Wi-Fi driver init fails and shell crashes. Signed-off-by: Maochen Wang <[email protected]>
1 parent 6cbb37d commit 4174c95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,13 @@ const char *wifi_ps_exit_strategy_txt(enum wifi_ps_exit_strategy ps_exit_strateg
334334
static const struct wifi_mgmt_ops *const get_wifi_api(struct net_if *iface)
335335
{
336336
const struct device *dev = net_if_get_device(iface);
337-
struct net_wifi_mgmt_offload *off_api =
338-
(struct net_wifi_mgmt_offload *) dev->api;
337+
struct net_wifi_mgmt_offload *off_api;
338+
339+
if (dev == NULL) {
340+
return NULL;
341+
}
342+
343+
off_api = (struct net_wifi_mgmt_offload *) dev->api;
339344
#ifdef CONFIG_WIFI_NM
340345
struct wifi_nm_instance *nm = wifi_nm_get_instance_iface(iface);
341346

0 commit comments

Comments
 (0)