ipv6: sr: Use kmemdup instead of duplicating it in parse_nla_srh
authorYueHaibing <yuehaibing@huawei.com>
Mon, 23 Jul 2018 08:33:19 +0000 (16:33 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 23 Jul 2018 16:39:07 +0000 (09:39 -0700)
Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/seg6_local.c

index cd6e4cab63f6ca37e0bd7699ca1208ae94aad410..e1025b493a185ee8eaba0941c05bc293b025343f 100644 (file)
@@ -637,12 +637,10 @@ static int parse_nla_srh(struct nlattr **attrs, struct seg6_local_lwt *slwt)
        if (!seg6_validate_srh(srh, len))
                return -EINVAL;
 
-       slwt->srh = kmalloc(len, GFP_KERNEL);
+       slwt->srh = kmemdup(srh, len, GFP_KERNEL);
        if (!slwt->srh)
                return -ENOMEM;
 
-       memcpy(slwt->srh, srh, len);
-
        slwt->headroom += len;
 
        return 0;