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

kzalloc() to allocate fou is never called when udp_sock_create()
is failed. So, fou is always NULL in error label in this case.

Therefore, add a error_sock label and goto this label when
udp_sock_screate() is failed.

Signed-off-by: Kangmin Park <l4stpr0gr4m@gmail.com>
---
 net/ipv4/fou.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index e5f69b0bf3df..60d67ae76880 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -572,7 +572,7 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
 	/* Open UDP socket */
 	err = udp_sock_create(net, &cfg->udp_config, &sock);
 	if (err < 0)
-		goto error;
+		goto error_sock;
 
 	/* Allocate FOU port structure */
 	fou = kzalloc(sizeof(*fou), GFP_KERNEL);
@@ -627,9 +627,9 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
 
 error:
 	kfree(fou);
+error_sock:
 	if (sock)
 		udp_tunnel_sock_release(sock);
-
 	return err;
 }
 
-- 
2.26.2


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-08  3:21 [PATCH] 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).