netfilter:ipvs: use kmemdup
authorShan Wei <shanwei@cn.fujitsu.com>
Mon, 7 Mar 2011 02:11:34 +0000 (10:11 +0800)
committerSimon Horman <horms@verge.net.au>
Tue, 15 Mar 2011 00:36:49 +0000 (09:36 +0900)
The semantic patch that makes this output is available
in scripts/coccinelle/api/memdup.cocci.

More information about semantic patching is available at
http://coccinelle.lip6.fr/

Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
net/netfilter/ipvs/ip_vs_pe_sip.c
net/netfilter/ipvs/ip_vs_sync.c

index 0d83bc01fed4c14d7323debd536c5ca738cd5954..13d607ae9c526a2372fc7340a9b2c8e403fbd97b 100644 (file)
@@ -92,14 +92,13 @@ ip_vs_sip_fill_param(struct ip_vs_conn_param *p, struct sk_buff *skb)
        if (get_callid(dptr, dataoff, datalen, &matchoff, &matchlen))
                return -EINVAL;
 
-       p->pe_data = kmalloc(matchlen, GFP_ATOMIC);
-       if (!p->pe_data)
-               return -ENOMEM;
-
        /* N.B: pe_data is only set on success,
         * this allows fallback to the default persistence logic on failure
         */
-       memcpy(p->pe_data, dptr + matchoff, matchlen);
+       p->pe_data = kmemdup(dptr + matchoff, matchlen, GFP_ATOMIC);
+       if (!p->pe_data)
+               return -ENOMEM;
+
        p->pe_data_len = matchlen;
 
        return 0;
index fecf24de4af32a5b39db3a7f58edc6c4c9b81e08..c5d13b05275a2c21e4fa34e8ab9d4d639d5b6806 100644 (file)
@@ -697,13 +697,12 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
                        return 1;
                }
 
-               p->pe_data = kmalloc(pe_data_len, GFP_ATOMIC);
+               p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
                if (!p->pe_data) {
                        if (p->pe->module)
                                module_put(p->pe->module);
                        return -ENOMEM;
                }
-               memcpy(p->pe_data, pe_data, pe_data_len);
                p->pe_data_len = pe_data_len;
        }
        return 0;