Skip to content

Commit

Permalink
net: ipv6: rpl_iptunnel: Fix potential memory leak in rpl_do_srh_inline
Browse files Browse the repository at this point in the history
In case memory resources for buf were allocated, release them before
return.

Addresses-Coverity-ID: 1492011 ("Resource leak")
Fixes: a7a29f9 ("net: ipv6: add rpl sr tunnel")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gustavo A. R. Silva authored and David S. Miller committed Mar 31, 2020
1 parent a019043 commit 7f80ccf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/ipv6/rpl_iptunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ static int rpl_do_srh_inline(struct sk_buff *skb, const struct rpl_lwt *rlwt,
hdrlen = ((csrh->hdrlen + 1) << 3);

err = skb_cow_head(skb, hdrlen + skb->mac_len);
if (unlikely(err))
if (unlikely(err)) {
kfree(buf);
return err;
}

skb_pull(skb, sizeof(struct ipv6hdr));
skb_postpull_rcsum(skb, skb_network_header(skb),
Expand Down

0 comments on commit 7f80ccf

Please sign in to comment.