netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, martin.varghese@nokia.com,
	willemb@google.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net] net: bareudp: add missing error handling for bareudp_link_config()
Date: Wed, 30 Dec 2020 19:44:17 -0800	[thread overview]
Message-ID: <20201231034417.1570553-1-kuba@kernel.org> (raw)

.dellink does not get called after .newlink fails,
bareudp_newlink() must undo what bareudp_configure()
has done if bareudp_link_config() fails.

Fixes: 571912c69f0e ("net: UDP tunnel encapsulation module for tunnelling different protocols like MPLS, IP, NSH etc.")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
Found by code inspection and compile-tested only.

 drivers/net/bareudp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index 85ebd2b7e446..7a03a9059ccc 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -648,6 +648,7 @@ static int bareudp_newlink(struct net *net, struct net_device *dev,
 			   struct nlattr *tb[], struct nlattr *data[],
 			   struct netlink_ext_ack *extack)
 {
+	struct bareudp_dev *bareudp = netdev_priv(dev);
 	struct bareudp_conf conf;
 	int err;
 
@@ -661,9 +662,14 @@ static int bareudp_newlink(struct net *net, struct net_device *dev,
 
 	err = bareudp_link_config(dev, tb);
 	if (err)
-		return err;
+		goto err_unconfig;
 
 	return 0;
+
+err_unconfig:
+	list_del(&bareudp->next);
+	unregister_netdevice(dev);
+	return err;
 }
 
 static void bareudp_dellink(struct net_device *dev, struct list_head *head)
-- 
2.26.2


             reply	other threads:[~2020-12-31  3:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31  3:44 Jakub Kicinski [this message]
2021-01-02 23:49 ` [PATCH net] net: bareudp: add missing error handling for bareudp_link_config() Cong Wang
2021-01-04 17:49   ` Jakub Kicinski
2021-01-05  6:22     ` Cong Wang

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=20201231034417.1570553-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=martin.varghese@nokia.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    /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 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).