Commit bf722d1d authored by Yair Shapira's avatar Yair Shapira Committed by Luciano Coelho

wlcore: make usage of nla_put clearer

handle errors of nla_put() inside the if(nla_put...) {}

This makes the code simpler and clearer because:
we take advantage from the fact that we have only one nla_put
in our routines (so no real need for goto label).
this avoids ugly goto forward followed by goto backward.
Signed-off-by: default avatarYair Shapira <yair.shapira@ti.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent ff324317
...@@ -129,8 +129,12 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -129,8 +129,12 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[])
goto out_sleep; goto out_sleep;
} }
if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) if (nla_put(skb, WL1271_TM_ATTR_DATA, buf_len, buf)) {
goto nla_put_failure; kfree_skb(skb);
ret = -EMSGSIZE;
goto out_sleep;
}
ret = cfg80211_testmode_reply(skb); ret = cfg80211_testmode_reply(skb);
if (ret < 0) if (ret < 0)
goto out_sleep; goto out_sleep;
...@@ -142,11 +146,6 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -142,11 +146,6 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[])
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
return ret; return ret;
nla_put_failure:
kfree_skb(skb);
ret = -EMSGSIZE;
goto out_sleep;
} }
static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
...@@ -192,8 +191,12 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -192,8 +191,12 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
goto out_free; goto out_free;
} }
if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) if (nla_put(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd)) {
goto nla_put_failure; kfree_skb(skb);
ret = -EMSGSIZE;
goto out_free;
}
ret = cfg80211_testmode_reply(skb); ret = cfg80211_testmode_reply(skb);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
...@@ -206,11 +209,6 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -206,11 +209,6 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[])
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
return ret; return ret;
nla_put_failure:
kfree_skb(skb);
ret = -EMSGSIZE;
goto out_free;
} }
static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[])
...@@ -343,8 +341,12 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -343,8 +341,12 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
goto out; goto out;
} }
if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) if (nla_put(skb, WL1271_TM_ATTR_DATA, ETH_ALEN, mac_addr)) {
goto nla_put_failure; kfree_skb(skb);
ret = -EMSGSIZE;
goto out;
}
ret = cfg80211_testmode_reply(skb); ret = cfg80211_testmode_reply(skb);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -352,11 +354,6 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[]) ...@@ -352,11 +354,6 @@ static int wl12xx_tm_cmd_get_mac(struct wl1271 *wl, struct nlattr *tb[])
out: out:
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
return ret; return ret;
nla_put_failure:
kfree_skb(skb);
ret = -EMSGSIZE;
goto out;
} }
int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len) int wl1271_tm_cmd(struct ieee80211_hw *hw, void *data, int len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment