@@ -1252,8 +1252,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
return -EINVAL;
sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
- if (!sta)
- return -ENOMEM;
+ if (IS_ERR(sta))
+ return PTR_ERR(sta);
/*
* defaults -- if userspace wants something else we'll
@@ -641,7 +641,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, const u8 *bssid,
rcu_read_unlock();
sta = sta_info_alloc(sdata, addr, GFP_KERNEL);
- if (!sta) {
+ if (IS_ERR(sta)) {
rcu_read_lock();
return NULL;
}
@@ -1231,7 +1231,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
rcu_read_unlock();
sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
- if (!sta)
+ if (IS_ERR(sta))
return;
sta->last_rx = jiffies;
@@ -674,8 +674,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
/* Create STA entry for the WDS peer */
sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
GFP_KERNEL);
- if (!sta) {
- res = -ENOMEM;
+ if (IS_ERR(sta)) {
+ res = PTR_ERR(sta);
goto err_del_interface;
}
@@ -471,7 +471,7 @@ __mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *hw_addr)
return NULL;
sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
- if (!sta)
+ if (IS_ERR(sta))
return NULL;
sta->mesh->plink_state = NL80211_PLINK_LISTEN;
@@ -4330,8 +4330,8 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
if (!have_sta) {
new_sta = sta_info_alloc(sdata, cbss->bssid, GFP_KERNEL);
- if (!new_sta)
- return -ENOMEM;
+ if (IS_ERR(new_sta))
+ return PTR_ERR(new_sta);
}
if (new_sta || override) {
@@ -72,7 +72,7 @@ void ieee80211_ocb_rx_no_sta(struct ieee80211_sub_if_data *sdata,
rcu_read_unlock();
sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
- if (!sta)
+ if (IS_ERR(sta))
return;
sta->last_rx = jiffies;
@@ -304,11 +304,11 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
struct ieee80211_hw *hw = &local->hw;
struct sta_info *sta;
struct timespec uptime;
- int i;
+ int i, ret;
sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp);
if (!sta)
- return NULL;
+ return ERR_PTR(-ENOMEM);
spin_lock_init(&sta->lock);
spin_lock_init(&sta->ps_lock);
@@ -318,8 +318,10 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
#ifdef CONFIG_MAC80211_MESH
if (ieee80211_vif_is_mesh(&sdata->vif)) {
sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);
- if (!sta->mesh)
+ if (!sta->mesh) {
+ ret = -ENOMEM;
goto free;
+ }
spin_lock_init(&sta->mesh->plink_lock);
if (ieee80211_vif_is_mesh(&sdata->vif) &&
!sdata->u.mesh.user_mpm)
@@ -351,8 +353,10 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
ALIGN(hw->txq_data_size, sizeof(void *));
txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp);
- if (!txq_data)
+ if (!txq_data) {
+ ret = -ENOMEM;
goto free;
+ }
for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
struct txq_info *txq = txq_data + i * size;
@@ -361,7 +365,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
}
}
- if (sta_prepare_rate_control(local, sta, gfp))
+ ret = sta_prepare_rate_control(local, sta, gfp);
+ if (ret)
goto free_txq;
for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
@@ -418,7 +423,7 @@ free:
kfree(sta->mesh);
#endif
kfree(sta);
- return NULL;
+ return ERR_PTR(ret);
}
static int sta_info_insert_check(struct sta_info *sta)