All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kangmin Park <l4stpr0gr4m@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ipv4: fix error path in fou_create()
Date: Sun,  8 Aug 2021 12:21:57 +0900	[thread overview]
Message-ID: <20210808032157.2439-1-l4stpr0gr4m@gmail.com> (raw)

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


                 reply	other threads:[~2021-08-08  3:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210808032157.2439-1-l4stpr0gr4m@gmail.com \
    --to=l4stpr0gr4m@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.