diff options
author | David S. Miller <davem@davemloft.net> | 2012-04-01 20:45:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-02 04:33:43 -0400 |
commit | be51da0f3e346eb520c4ffdaecb8ba6fb4337a76 (patch) | |
tree | f24394d7d8703e03c2b893eb6a60efe6bda5eaad /net/ieee802154/nl-phy.c | |
parent | d317e4f68f5445e536dbd45381e7c900a33413db (diff) |
ieee802154: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154/nl-phy.c')
-rw-r--r-- | net/ieee802154/nl-phy.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c index c64a38d57aa3..3bdc4303c339 100644 --- a/net/ieee802154/nl-phy.c +++ b/net/ieee802154/nl-phy.c | |||
@@ -53,18 +53,18 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid, | |||
53 | goto out; | 53 | goto out; |
54 | 54 | ||
55 | mutex_lock(&phy->pib_lock); | 55 | mutex_lock(&phy->pib_lock); |
56 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 56 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
57 | 57 | nla_put_u8(msg, IEEE802154_ATTR_PAGE, phy->current_page) || | |
58 | NLA_PUT_U8(msg, IEEE802154_ATTR_PAGE, phy->current_page); | 58 | nla_put_u8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel)) |
59 | NLA_PUT_U8(msg, IEEE802154_ATTR_CHANNEL, phy->current_channel); | 59 | goto nla_put_failure; |
60 | for (i = 0; i < 32; i++) { | 60 | for (i = 0; i < 32; i++) { |
61 | if (phy->channels_supported[i]) | 61 | if (phy->channels_supported[i]) |
62 | buf[pages++] = phy->channels_supported[i] | (i << 27); | 62 | buf[pages++] = phy->channels_supported[i] | (i << 27); |
63 | } | 63 | } |
64 | if (pages) | 64 | if (pages && |
65 | NLA_PUT(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST, | 65 | nla_put(msg, IEEE802154_ATTR_CHANNEL_PAGE_LIST, |
66 | pages * sizeof(uint32_t), buf); | 66 | pages * sizeof(uint32_t), buf)) |
67 | 67 | goto nla_put_failure; | |
68 | mutex_unlock(&phy->pib_lock); | 68 | mutex_unlock(&phy->pib_lock); |
69 | kfree(buf); | 69 | kfree(buf); |
70 | return genlmsg_end(msg, hdr); | 70 | return genlmsg_end(msg, hdr); |
@@ -245,9 +245,9 @@ static int ieee802154_add_iface(struct sk_buff *skb, | |||
245 | goto dev_unregister; | 245 | goto dev_unregister; |
246 | } | 246 | } |
247 | 247 | ||
248 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 248 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || |
249 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, dev->name); | 249 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, dev->name)) |
250 | 250 | goto nla_put_failure; | |
251 | dev_put(dev); | 251 | dev_put(dev); |
252 | 252 | ||
253 | wpan_phy_put(phy); | 253 | wpan_phy_put(phy); |
@@ -333,10 +333,9 @@ static int ieee802154_del_iface(struct sk_buff *skb, | |||
333 | 333 | ||
334 | rtnl_unlock(); | 334 | rtnl_unlock(); |
335 | 335 | ||
336 | 336 | if (nla_put_string(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)) || | |
337 | NLA_PUT_STRING(msg, IEEE802154_ATTR_PHY_NAME, wpan_phy_name(phy)); | 337 | nla_put_string(msg, IEEE802154_ATTR_DEV_NAME, name)) |
338 | NLA_PUT_STRING(msg, IEEE802154_ATTR_DEV_NAME, name); | 338 | goto nla_put_failure; |
339 | |||
340 | wpan_phy_put(phy); | 339 | wpan_phy_put(phy); |
341 | 340 | ||
342 | return ieee802154_nl_reply(msg, info); | 341 | return ieee802154_nl_reply(msg, info); |