diff options
Diffstat (limited to 'net/sched/cls_bpf.c')
-rw-r--r-- | net/sched/cls_bpf.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 84c8219c3e1c..f59adf8a4cd7 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c | |||
@@ -180,6 +180,11 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp, | |||
180 | } | 180 | } |
181 | 181 | ||
182 | bpf_size = bpf_len * sizeof(*bpf_ops); | 182 | bpf_size = bpf_len * sizeof(*bpf_ops); |
183 | if (bpf_size != nla_len(tb[TCA_BPF_OPS])) { | ||
184 | ret = -EINVAL; | ||
185 | goto errout; | ||
186 | } | ||
187 | |||
183 | bpf_ops = kzalloc(bpf_size, GFP_KERNEL); | 188 | bpf_ops = kzalloc(bpf_size, GFP_KERNEL); |
184 | if (bpf_ops == NULL) { | 189 | if (bpf_ops == NULL) { |
185 | ret = -ENOMEM; | 190 | ret = -ENOMEM; |
@@ -215,15 +220,21 @@ static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp, | |||
215 | struct cls_bpf_head *head) | 220 | struct cls_bpf_head *head) |
216 | { | 221 | { |
217 | unsigned int i = 0x80000000; | 222 | unsigned int i = 0x80000000; |
223 | u32 handle; | ||
218 | 224 | ||
219 | do { | 225 | do { |
220 | if (++head->hgen == 0x7FFFFFFF) | 226 | if (++head->hgen == 0x7FFFFFFF) |
221 | head->hgen = 1; | 227 | head->hgen = 1; |
222 | } while (--i > 0 && cls_bpf_get(tp, head->hgen)); | 228 | } while (--i > 0 && cls_bpf_get(tp, head->hgen)); |
223 | if (i == 0) | 229 | |
230 | if (unlikely(i == 0)) { | ||
224 | pr_err("Insufficient number of handles\n"); | 231 | pr_err("Insufficient number of handles\n"); |
232 | handle = 0; | ||
233 | } else { | ||
234 | handle = head->hgen; | ||
235 | } | ||
225 | 236 | ||
226 | return i; | 237 | return handle; |
227 | } | 238 | } |
228 | 239 | ||
229 | static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, | 240 | static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, |