aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/sched/act_ipt.c6
-rw-r--r--net/sched/act_simple.c3
-rw-r--r--net/sched/cls_api.c3
-rw-r--r--net/sched/em_meta.c3
-rw-r--r--net/sched/em_nbyte.c4
-rw-r--r--net/sched/ematch.c3
6 files changed, 7 insertions, 15 deletions
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index d8c9310da6e5..a9608064a4c3 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -156,10 +156,9 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
156 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ) 156 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ)
157 strcpy(tname, "mangle"); 157 strcpy(tname, "mangle");
158 158
159 t = kmalloc(td->u.target_size, GFP_KERNEL); 159 t = kmemdup(td, td->u.target_size, GFP_KERNEL);
160 if (unlikely(!t)) 160 if (unlikely(!t))
161 goto err2; 161 goto err2;
162 memcpy(t, td, td->u.target_size);
163 162
164 if ((err = ipt_init_target(t, tname, hook)) < 0) 163 if ((err = ipt_init_target(t, tname, hook)) < 0)
165 goto err3; 164 goto err3;
@@ -256,13 +255,12 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
256 ** for foolproof you need to not assume this 255 ** for foolproof you need to not assume this
257 */ 256 */
258 257
259 t = kmalloc(ipt->tcfi_t->u.user.target_size, GFP_ATOMIC); 258 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
260 if (unlikely(!t)) 259 if (unlikely(!t))
261 goto rtattr_failure; 260 goto rtattr_failure;
262 261
263 c.bindcnt = ipt->tcf_bindcnt - bind; 262 c.bindcnt = ipt->tcf_bindcnt - bind;
264 c.refcnt = ipt->tcf_refcnt - ref; 263 c.refcnt = ipt->tcf_refcnt - ref;
265 memcpy(t, ipt->tcfi_t, ipt->tcfi_t->u.user.target_size);
266 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); 264 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
267 265
268 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t); 266 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 901571a67707..5fe80854ca91 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -71,11 +71,10 @@ static int tcf_simp_release(struct tcf_defact *d, int bind)
71 71
72static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) 72static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata)
73{ 73{
74 d->tcfd_defdata = kmalloc(datalen, GFP_KERNEL); 74 d->tcfd_defdata = kmemdup(defdata, datalen, GFP_KERNEL);
75 if (unlikely(!d->tcfd_defdata)) 75 if (unlikely(!d->tcfd_defdata))
76 return -ENOMEM; 76 return -ENOMEM;
77 d->tcfd_datalen = datalen; 77 d->tcfd_datalen = datalen;
78 memcpy(d->tcfd_defdata, defdata, datalen);
79 return 0; 78 return 0;
80} 79}
81 80
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 37a184021647..edb8fc97ae11 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -217,7 +217,7 @@ replay:
217 /* Create new proto tcf */ 217 /* Create new proto tcf */
218 218
219 err = -ENOBUFS; 219 err = -ENOBUFS;
220 if ((tp = kmalloc(sizeof(*tp), GFP_KERNEL)) == NULL) 220 if ((tp = kzalloc(sizeof(*tp), GFP_KERNEL)) == NULL)
221 goto errout; 221 goto errout;
222 err = -EINVAL; 222 err = -EINVAL;
223 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]); 223 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]);
@@ -247,7 +247,6 @@ replay:
247 kfree(tp); 247 kfree(tp);
248 goto errout; 248 goto errout;
249 } 249 }
250 memset(tp, 0, sizeof(*tp));
251 tp->ops = tp_ops; 250 tp->ops = tp_ops;
252 tp->protocol = protocol; 251 tp->protocol = protocol;
253 tp->prio = nprio ? : tcf_auto_prio(*back); 252 tp->prio = nprio ? : tcf_auto_prio(*back);
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index d3ff3503326a..45d47d37155e 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -546,10 +546,9 @@ static int meta_var_change(struct meta_value *dst, struct rtattr *rta)
546{ 546{
547 int len = RTA_PAYLOAD(rta); 547 int len = RTA_PAYLOAD(rta);
548 548
549 dst->val = (unsigned long) kmalloc(len, GFP_KERNEL); 549 dst->val = (unsigned long)kmemdup(RTA_DATA(rta), len, GFP_KERNEL);
550 if (dst->val == 0UL) 550 if (dst->val == 0UL)
551 return -ENOMEM; 551 return -ENOMEM;
552 memcpy((void *) dst->val, RTA_DATA(rta), len);
553 dst->len = len; 552 dst->len = len;
554 return 0; 553 return 0;
555} 554}
diff --git a/net/sched/em_nbyte.c b/net/sched/em_nbyte.c
index cc80babfd79f..005db409be64 100644
--- a/net/sched/em_nbyte.c
+++ b/net/sched/em_nbyte.c
@@ -34,12 +34,10 @@ static int em_nbyte_change(struct tcf_proto *tp, void *data, int data_len,
34 return -EINVAL; 34 return -EINVAL;
35 35
36 em->datalen = sizeof(*nbyte) + nbyte->len; 36 em->datalen = sizeof(*nbyte) + nbyte->len;
37 em->data = (unsigned long) kmalloc(em->datalen, GFP_KERNEL); 37 em->data = (unsigned long)kmemdup(data, em->datalen, GFP_KERNEL);
38 if (em->data == 0UL) 38 if (em->data == 0UL)
39 return -ENOBUFS; 39 return -ENOBUFS;
40 40
41 memcpy((void *) em->data, data, em->datalen);
42
43 return 0; 41 return 0;
44} 42}
45 43
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 0fd0768a17c6..8f8a16da72a8 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -251,12 +251,11 @@ static int tcf_em_validate(struct tcf_proto *tp,
251 goto errout; 251 goto errout;
252 em->data = *(u32 *) data; 252 em->data = *(u32 *) data;
253 } else { 253 } else {
254 void *v = kmalloc(data_len, GFP_KERNEL); 254 void *v = kmemdup(data, data_len, GFP_KERNEL);
255 if (v == NULL) { 255 if (v == NULL) {
256 err = -ENOBUFS; 256 err = -ENOBUFS;
257 goto errout; 257 goto errout;
258 } 258 }
259 memcpy(v, data, data_len);
260 em->data = (unsigned long) v; 259 em->data = (unsigned long) v;
261 } 260 }
262 } 261 }