netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ipv6: rpl_iptunnel: Fix potential memory leak in rpl_do_srh_inline
@ 2020-03-31 16:35 Gustavo A. R. Silva
  2020-03-31 17:13 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-31 16:35 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI,
	Jakub Kicinski, Alexander Aring
  Cc: netdev, linux-kernel, Gustavo A. R. Silva

In case memory resources for buf were allocated, release them before
return.

Addresses-Coverity-ID: 1492011 ("Resource leak")
Fixes: a7a29f9c361f ("net: ipv6: add rpl sr tunnel")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/ipv6/rpl_iptunnel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/rpl_iptunnel.c b/net/ipv6/rpl_iptunnel.c
index 203037afe001..a49ddc6cd020 100644
--- a/net/ipv6/rpl_iptunnel.c
+++ b/net/ipv6/rpl_iptunnel.c
@@ -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),
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: ipv6: rpl_iptunnel: Fix potential memory leak in rpl_do_srh_inline
  2020-03-31 16:35 [PATCH net-next] net: ipv6: rpl_iptunnel: Fix potential memory leak in rpl_do_srh_inline Gustavo A. R. Silva
@ 2020-03-31 17:13 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-03-31 17:13 UTC (permalink / raw)
  To: gustavo; +Cc: kuznet, yoshfuji, kuba, alex.aring, netdev, linux-kernel

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Tue, 31 Mar 2020 11:35:06 -0500

> In case memory resources for buf were allocated, release them before
> return.
> 
> Addresses-Coverity-ID: 1492011 ("Resource leak")
> Fixes: a7a29f9c361f ("net: ipv6: add rpl sr tunnel")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-31 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-31 16:35 [PATCH net-next] net: ipv6: rpl_iptunnel: Fix potential memory leak in rpl_do_srh_inline Gustavo A. R. Silva
2020-03-31 17:13 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).