Skip to contentSkip to conversation

ipv4: fix error path in fou_create()

PATCH Superseded Kangmin Park 1 participant 1 message Aug 8, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: fix error path in fou_create()

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.

---
 net/ipv4/fou.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/fou.c +2 -2
index e5f69b0bf3df..60d67ae76880 100644
@@ -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;
 }
 
Signature · 1 line
2.26.2