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/cls_u32.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/cls_u32.c')
-rw-r--r-- | net/sched/cls_u32.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 939b627b4795..591b006a8c5a 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -733,36 +733,44 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, | |||
733 | struct tc_u_hnode *ht = (struct tc_u_hnode *)fh; | 733 | struct tc_u_hnode *ht = (struct tc_u_hnode *)fh; |
734 | u32 divisor = ht->divisor + 1; | 734 | u32 divisor = ht->divisor + 1; |
735 | 735 | ||
736 | NLA_PUT_U32(skb, TCA_U32_DIVISOR, divisor); | 736 | if (nla_put_u32(skb, TCA_U32_DIVISOR, divisor)) |
737 | goto nla_put_failure; | ||
737 | } else { | 738 | } else { |
738 | NLA_PUT(skb, TCA_U32_SEL, | 739 | if (nla_put(skb, TCA_U32_SEL, |
739 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), | 740 | sizeof(n->sel) + n->sel.nkeys*sizeof(struct tc_u32_key), |
740 | &n->sel); | 741 | &n->sel)) |
742 | goto nla_put_failure; | ||
741 | if (n->ht_up) { | 743 | if (n->ht_up) { |
742 | u32 htid = n->handle & 0xFFFFF000; | 744 | u32 htid = n->handle & 0xFFFFF000; |
743 | NLA_PUT_U32(skb, TCA_U32_HASH, htid); | 745 | if (nla_put_u32(skb, TCA_U32_HASH, htid)) |
746 | goto nla_put_failure; | ||
744 | } | 747 | } |
745 | if (n->res.classid) | 748 | if (n->res.classid && |
746 | NLA_PUT_U32(skb, TCA_U32_CLASSID, n->res.classid); | 749 | nla_put_u32(skb, TCA_U32_CLASSID, n->res.classid)) |
747 | if (n->ht_down) | 750 | goto nla_put_failure; |
748 | NLA_PUT_U32(skb, TCA_U32_LINK, n->ht_down->handle); | 751 | if (n->ht_down && |
752 | nla_put_u32(skb, TCA_U32_LINK, n->ht_down->handle)) | ||
753 | goto nla_put_failure; | ||
749 | 754 | ||
750 | #ifdef CONFIG_CLS_U32_MARK | 755 | #ifdef CONFIG_CLS_U32_MARK |
751 | if (n->mark.val || n->mark.mask) | 756 | if ((n->mark.val || n->mark.mask) && |
752 | NLA_PUT(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark); | 757 | nla_put(skb, TCA_U32_MARK, sizeof(n->mark), &n->mark)) |
758 | goto nla_put_failure; | ||
753 | #endif | 759 | #endif |
754 | 760 | ||
755 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) | 761 | if (tcf_exts_dump(skb, &n->exts, &u32_ext_map) < 0) |
756 | goto nla_put_failure; | 762 | goto nla_put_failure; |
757 | 763 | ||
758 | #ifdef CONFIG_NET_CLS_IND | 764 | #ifdef CONFIG_NET_CLS_IND |
759 | if (strlen(n->indev)) | 765 | if (strlen(n->indev) && |
760 | NLA_PUT_STRING(skb, TCA_U32_INDEV, n->indev); | 766 | nla_put_string(skb, TCA_U32_INDEV, n->indev)) |
767 | goto nla_put_failure; | ||
761 | #endif | 768 | #endif |
762 | #ifdef CONFIG_CLS_U32_PERF | 769 | #ifdef CONFIG_CLS_U32_PERF |
763 | NLA_PUT(skb, TCA_U32_PCNT, | 770 | if (nla_put(skb, TCA_U32_PCNT, |
764 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), | 771 | sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(u64), |
765 | n->pf); | 772 | n->pf)) |
773 | goto nla_put_failure; | ||
766 | #endif | 774 | #endif |
767 | } | 775 | } |
768 | 776 | ||