[NET] neighbour: Use kmemdup where applicable
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Tue, 21 Nov 2006 03:15:32 +0000 (01:15 -0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:30:14 +0000 (21:30 -0800)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
net/core/neighbour.c

index 0e097ba14d733a4f092b1bca0b8ee2c24de4fbda..ba509a4a8e92939d9dbbbbed4ee432822979d217 100644 (file)
@@ -1266,10 +1266,9 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
 struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
                                      struct neigh_table *tbl)
 {
-       struct neigh_parms *p = kmalloc(sizeof(*p), GFP_KERNEL);
+       struct neigh_parms *p = kmemdup(&tbl->parms, sizeof(*p), GFP_KERNEL);
 
        if (p) {
-               memcpy(p, &tbl->parms, sizeof(*p));
                p->tbl            = tbl;
                atomic_set(&p->refcnt, 1);
                INIT_RCU_HEAD(&p->rcu_head);
@@ -2625,14 +2624,14 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
                          int p_id, int pdev_id, char *p_name, 
                          proc_handler *handler, ctl_handler *strategy)
 {
-       struct neigh_sysctl_table *t = kmalloc(sizeof(*t), GFP_KERNEL);
+       struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template,
+                                              sizeof(*t), GFP_KERNEL);
        const char *dev_name_source = NULL;
        char *dev_name = NULL;
        int err = 0;
 
        if (!t)
                return -ENOBUFS;
-       memcpy(t, &neigh_sysctl_template, sizeof(*t));
        t->neigh_vars[0].data  = &p->mcast_probes;
        t->neigh_vars[1].data  = &p->ucast_probes;
        t->neigh_vars[2].data  = &p->app_probes;