summaryrefslogtreecommitdiffstats
path: root/net/ipv6/rpl_iptunnel.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2020-06-23 01:07:41 +0200
committerDavid S. Miller <davem@davemloft.net>2020-06-24 05:27:09 +0200
commit6f3934576853a4fa60dea74ac8822f0f016ef9e8 (patch)
tree04951421e617a66f3d9d007a57db9092de5d605f /net/ipv6/rpl_iptunnel.c
parentxirc2ps_cs: remove dev null check from do_reset(). (diff)
downloadlinux-6f3934576853a4fa60dea74ac8822f0f016ef9e8.tar.xz
linux-6f3934576853a4fa60dea74ac8822f0f016ef9e8.zip
net: ipv6: Use struct_size() helper and kcalloc()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. Also, remove unnecessary function ipv6_rpl_srh_alloc_size() and replace kzalloc() with kcalloc(), which has a 2-factor argument form for multiplication. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/rpl_iptunnel.c')
-rw-r--r--net/ipv6/rpl_iptunnel.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/ipv6/rpl_iptunnel.c b/net/ipv6/rpl_iptunnel.c
index c3ececd7cfc1..5fdf3ebb953f 100644
--- a/net/ipv6/rpl_iptunnel.c
+++ b/net/ipv6/rpl_iptunnel.c
@@ -136,8 +136,7 @@ static int rpl_do_srh_inline(struct sk_buff *skb, const struct rpl_lwt *rlwt,
oldhdr = ipv6_hdr(skb);
- buf = kzalloc(ipv6_rpl_srh_alloc_size(srh->segments_left - 1) * 2,
- GFP_ATOMIC);
+ buf = kcalloc(struct_size(srh, segments.addr, srh->segments_left), 2, GFP_ATOMIC);
if (!buf)
return -ENOMEM;