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)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

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.

---
v2:
- change commit message
- fix error path

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