diff options
author | David S. Miller <davem@davemloft.net> | 2012-03-29 05:11:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-01 18:11:37 -0400 |
commit | 1b34ec43c9b3de44a5420841ab293d1b2035a94c (patch) | |
tree | 8d6cf966c813e0e61001655179b5ef8e5f1b54b3 /net/sched/sch_netem.c | |
parent | 9360ffd1859720f6520cf59241909b74dae369d0 (diff) |
pkt_sched: 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/sched/sch_netem.c')
-rw-r--r-- | net/sched/sch_netem.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 5da548fa7ae9..110973145a4b 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -834,7 +834,8 @@ static int dump_loss_model(const struct netem_sched_data *q, | |||
834 | .p23 = q->clg.a5, | 834 | .p23 = q->clg.a5, |
835 | }; | 835 | }; |
836 | 836 | ||
837 | NLA_PUT(skb, NETEM_LOSS_GI, sizeof(gi), &gi); | 837 | if (nla_put(skb, NETEM_LOSS_GI, sizeof(gi), &gi)) |
838 | goto nla_put_failure; | ||
838 | break; | 839 | break; |
839 | } | 840 | } |
840 | case CLG_GILB_ELL: { | 841 | case CLG_GILB_ELL: { |
@@ -845,7 +846,8 @@ static int dump_loss_model(const struct netem_sched_data *q, | |||
845 | .k1 = q->clg.a4, | 846 | .k1 = q->clg.a4, |
846 | }; | 847 | }; |
847 | 848 | ||
848 | NLA_PUT(skb, NETEM_LOSS_GE, sizeof(ge), &ge); | 849 | if (nla_put(skb, NETEM_LOSS_GE, sizeof(ge), &ge)) |
850 | goto nla_put_failure; | ||
849 | break; | 851 | break; |
850 | } | 852 | } |
851 | } | 853 | } |
@@ -874,26 +876,31 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) | |||
874 | qopt.loss = q->loss; | 876 | qopt.loss = q->loss; |
875 | qopt.gap = q->gap; | 877 | qopt.gap = q->gap; |
876 | qopt.duplicate = q->duplicate; | 878 | qopt.duplicate = q->duplicate; |
877 | NLA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt); | 879 | if (nla_put(skb, TCA_OPTIONS, sizeof(qopt), &qopt)) |
880 | goto nla_put_failure; | ||
878 | 881 | ||
879 | cor.delay_corr = q->delay_cor.rho; | 882 | cor.delay_corr = q->delay_cor.rho; |
880 | cor.loss_corr = q->loss_cor.rho; | 883 | cor.loss_corr = q->loss_cor.rho; |
881 | cor.dup_corr = q->dup_cor.rho; | 884 | cor.dup_corr = q->dup_cor.rho; |
882 | NLA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor); | 885 | if (nla_put(skb, TCA_NETEM_CORR, sizeof(cor), &cor)) |
886 | goto nla_put_failure; | ||
883 | 887 | ||
884 | reorder.probability = q->reorder; | 888 | reorder.probability = q->reorder; |
885 | reorder.correlation = q->reorder_cor.rho; | 889 | reorder.correlation = q->reorder_cor.rho; |
886 | NLA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder); | 890 | if (nla_put(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder)) |
891 | goto nla_put_failure; | ||
887 | 892 | ||
888 | corrupt.probability = q->corrupt; | 893 | corrupt.probability = q->corrupt; |
889 | corrupt.correlation = q->corrupt_cor.rho; | 894 | corrupt.correlation = q->corrupt_cor.rho; |
890 | NLA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt); | 895 | if (nla_put(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt)) |
896 | goto nla_put_failure; | ||
891 | 897 | ||
892 | rate.rate = q->rate; | 898 | rate.rate = q->rate; |
893 | rate.packet_overhead = q->packet_overhead; | 899 | rate.packet_overhead = q->packet_overhead; |
894 | rate.cell_size = q->cell_size; | 900 | rate.cell_size = q->cell_size; |
895 | rate.cell_overhead = q->cell_overhead; | 901 | rate.cell_overhead = q->cell_overhead; |
896 | NLA_PUT(skb, TCA_NETEM_RATE, sizeof(rate), &rate); | 902 | if (nla_put(skb, TCA_NETEM_RATE, sizeof(rate), &rate)) |
903 | goto nla_put_failure; | ||
897 | 904 | ||
898 | if (dump_loss_model(q, skb) != 0) | 905 | if (dump_loss_model(q, skb) != 0) |
899 | goto nla_put_failure; | 906 | goto nla_put_failure; |