Skip to content

Commit

Permalink
ipv6: sr: Use kmemdup instead of duplicating it in parse_nla_srh
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
YueHaibing authored and David S. Miller committed Jul 23, 2018
1 parent f8b2990 commit 7fa41ef
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/ipv6/seg6_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7fa41ef

Please sign in to comment.