diff mbox series

ipv4: fix error path in fou_create()

Message ID 20210808032157.2439-1-l4stpr0gr4m@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series ipv4: fix error path in fou_create() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/header_inline success Link

Commit Message

Kangmin Park Aug. 8, 2021, 3:21 a.m. UTC
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 mbox series

Patch

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;
 }