Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] ipv4: fix error path in fou_create()
@ 2021-08-08  5:49 Kangmin Park
  0 siblings, 0 replies; only message in thread
From: Kangmin Park @ 2021-08-08  5:49 UTC (permalink / raw)
  To: David S. Miller
  Cc: Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski, netdev, linux-kernel

sock is always NULL when udp_sock_create() is failed and fou is
always NULL when kzalloc() is failed.

So, add error_sock and error_alloc label and fix the error path
in those cases.

Signed-off-by: Kangmin Park <l4stpr0gr4m@gmail.com>
---
v2:
 - change commit message
 - fix error path

 net/ipv4/fou.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index 60d67ae76880..f1d99e776bb8 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -578,7 +578,7 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
 	fou = kzalloc(sizeof(*fou), GFP_KERNEL);
 	if (!fou) {
 		err = -ENOMEM;
-		goto error;
+		goto error_alloc;
 	}
 
 	sk = sock->sk;
@@ -627,9 +627,10 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
 
 error:
 	kfree(fou);
-error_sock:
+error_alloc:
 	if (sock)
 		udp_tunnel_sock_release(sock);
+error_sock:
 	return err;
 }
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-08  5:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-08  5:49 [PATCH v2] ipv4: fix error path in fou_create() Kangmin Park

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).