Subject: [PATCH 1/3] net: handle errors from device_rename

From: Stephen Hemminger <[email-masked]>
Date: Wed, 14 May 2008 18:15:43 -0700

device_rename can fail with -EEXIST or -ENOMEM, so handle any problems.

Signed-off-by: Stephen Hemminger <[email-masked]>

--- a/net/core/dev.c	2008-05-14 17:49:37.000000000 -0700
+++ b/net/core/dev.c	2008-05-14 17:51:21.000000000 -0700
@@ -903,7 +903,11 @@ int dev_change_name(struct net_device *d
 		strlcpy(dev->name, newname, IFNAMSIZ);
 
 rollback:
-	device_rename(&dev->dev, dev->name);
+	err = device_rename(&dev->dev, dev->name);
+	if (err) {
+		memcpy(dev->name, oldname, IFNAMSIZ);
+		return err;
+	}
 
 	write_lock_bh(&dev_base_lock);
 	hlist_del(&dev->name_hlist);