aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-04-01 21:03:30 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-02 04:33:45 -0400
commit633c938940cdb79d2a9e54f411f6c26ff09b451b (patch)
treede3910e810450bd760851db858e37ac3bd6b9130
parentd33e152e1edd2679cc2c49be0a3604fbabafece7 (diff)
mac80211_hwsim: 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>
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index b7ce6a6e355f..538783f51989 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -582,11 +582,13 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
582 goto nla_put_failure; 582 goto nla_put_failure;
583 } 583 }
584 584
585 NLA_PUT(skb, HWSIM_ATTR_ADDR_TRANSMITTER, 585 if (nla_put(skb, HWSIM_ATTR_ADDR_TRANSMITTER,
586 sizeof(struct mac_address), data->addresses[1].addr); 586 sizeof(struct mac_address), data->addresses[1].addr))
587 goto nla_put_failure;
587 588
588 /* We get the skb->data */ 589 /* We get the skb->data */
589 NLA_PUT(skb, HWSIM_ATTR_FRAME, my_skb->len, my_skb->data); 590 if (nla_put(skb, HWSIM_ATTR_FRAME, my_skb->len, my_skb->data))
591 goto nla_put_failure;
590 592
591 /* We get the flags for this transmission, and we translate them to 593 /* We get the flags for this transmission, and we translate them to
592 wmediumd flags */ 594 wmediumd flags */
@@ -597,7 +599,8 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
597 if (info->flags & IEEE80211_TX_CTL_NO_ACK) 599 if (info->flags & IEEE80211_TX_CTL_NO_ACK)
598 hwsim_flags |= HWSIM_TX_CTL_NO_ACK; 600 hwsim_flags |= HWSIM_TX_CTL_NO_ACK;
599 601
600 NLA_PUT_U32(skb, HWSIM_ATTR_FLAGS, hwsim_flags); 602 if (nla_put_u32(skb, HWSIM_ATTR_FLAGS, hwsim_flags))
603 goto nla_put_failure;
601 604
602 /* We get the tx control (rate and retries) info*/ 605 /* We get the tx control (rate and retries) info*/
603 606
@@ -606,12 +609,14 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
606 tx_attempts[i].count = info->status.rates[i].count; 609 tx_attempts[i].count = info->status.rates[i].count;
607 } 610 }
608 611
609 NLA_PUT(skb, HWSIM_ATTR_TX_INFO, 612 if (nla_put(skb, HWSIM_ATTR_TX_INFO,
610 sizeof(struct hwsim_tx_rate)*IEEE80211_TX_MAX_RATES, 613 sizeof(struct hwsim_tx_rate)*IEEE80211_TX_MAX_RATES,
611 tx_attempts); 614 tx_attempts))
615 goto nla_put_failure;
612 616
613 /* We create a cookie to identify this skb */ 617 /* We create a cookie to identify this skb */
614 NLA_PUT_U64(skb, HWSIM_ATTR_COOKIE, (unsigned long) my_skb); 618 if (nla_put_u64(skb, HWSIM_ATTR_COOKIE, (unsigned long) my_skb))
619 goto nla_put_failure;
615 620
616 genlmsg_end(skb, msg_head); 621 genlmsg_end(skb, msg_head);
617 genlmsg_unicast(&init_net, skb, dst_pid); 622 genlmsg_unicast(&init_net, skb, dst_pid);
@@ -1108,7 +1113,8 @@ static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw,
1108 nla_total_size(sizeof(u32))); 1113 nla_total_size(sizeof(u32)));
1109 if (!skb) 1114 if (!skb)
1110 return -ENOMEM; 1115 return -ENOMEM;
1111 NLA_PUT_U32(skb, HWSIM_TM_ATTR_PS, hwsim->ps); 1116 if (nla_put_u32(skb, HWSIM_TM_ATTR_PS, hwsim->ps))
1117 goto nla_put_failure;
1112 return cfg80211_testmode_reply(skb); 1118 return cfg80211_testmode_reply(skb);
1113 default: 1119 default:
1114 return -EOPNOTSUPP; 1120 return -EOPNOTSUPP;