netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: bareudp: add missing error handling for bareudp_link_config()
@ 2020-12-31  3:44 Jakub Kicinski
  2021-01-02 23:49 ` Cong Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2020-12-31  3:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, martin.varghese, willemb, Jakub Kicinski

.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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-05  6:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31  3:44 [PATCH net] net: bareudp: add missing error handling for bareudp_link_config() Jakub Kicinski
2021-01-02 23:49 ` Cong Wang
2021-01-04 17:49   ` Jakub Kicinski
2021-01-05  6:22     ` Cong Wang

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).