All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@suse.de>
To: Xen devel list <xen-devel@lists.xensource.com>
Cc: Kay Sievers <kasievers@suse.de>
Subject: [patch] fix netfront race
Date: Tue, 29 Aug 2006 09:34:55 +0200	[thread overview]
Message-ID: <44F3EE1F.3070308@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

  Hi,

this patch moves register_netdev() + sysfs attribute
registering from create_netdev() into the new open_netdev()
function. open_netdev is called as very last thing in
netdev_probe.

This closes at least one initialization race: uninitialized
mac address is visible for a short time in
/sys/class/net/${if}/address

please apply,

  Gerd

-- 
Gerd Hoffmann <kraxel@suse.de>
http://www.suse.de/~kraxel/julika-dora.jpeg

[-- Attachment #2: netfront-race --]
[-- Type: text/plain, Size: 2762 bytes --]

move register_netdev() + sysfs attribute registering from
create_netdev() into the new open_netdev() function.
open_netdev is called as very last thing in netdev_probe.

This closes at least one initialization race: uninitialized
mac address is visible for a short time in
/sys/class/net/${if}/address

Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
diff -r f790546ecfda linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Aug 28 20:22:56 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Aug 29 09:18:23 2006 +0200
@@ -193,6 +193,7 @@ static void netfront_closing(struct xenb
 
 static void end_access(int, void *);
 static void netif_disconnect_backend(struct netfront_info *);
+static int open_netdev(struct netfront_info *);
 static void close_netdev(struct netfront_info *);
 static void netif_free(struct netfront_info *);
 
@@ -263,15 +264,22 @@ static int __devinit netfront_probe(stru
 	dev->dev.driver_data = info;
 
 	err = talk_to_backend(dev, info);
-	if (err) {
-		xennet_sysfs_delif(info->netdev);
-		unregister_netdev(netdev);
-		free_netdev(netdev);
-		dev->dev.driver_data = NULL;
-		return err;
-	}
+	if (err)
+		goto fail_backend;
+
+	err = open_netdev(info);
+	if (err)
+		goto fail_open;
 
 	return 0;
+
+ fail_open:
+	xennet_sysfs_delif(info->netdev);
+	unregister_netdev(netdev);
+ fail_backend:
+	free_netdev(netdev);
+	dev->dev.driver_data = NULL;
+	return err;
 }
 
 
@@ -1887,27 +1895,9 @@ create_netdev(int handle, int copying_re
 	SET_MODULE_OWNER(netdev);
 	SET_NETDEV_DEV(netdev, &dev->dev);
 
-	err = register_netdev(netdev);
-	if (err) {
-		printk(KERN_WARNING "%s> register_netdev err=%d\n",
-		       __FUNCTION__, err);
-		goto exit_free_rx;
-	}
-
-	err = xennet_sysfs_addif(netdev);
-	if (err) {
-		/* This can be non-fatal: it only means no tuning parameters */
-		printk(KERN_WARNING "%s> add sysfs failed err=%d\n",
-		       __FUNCTION__, err);
-	}
-
 	np->netdev = netdev;
-
 	return netdev;
 
-
- exit_free_rx:
-	gnttab_free_grant_references(np->gref_rx_head);
  exit_free_tx:
 	gnttab_free_grant_references(np->gref_tx_head);
  exit:
@@ -1966,6 +1955,26 @@ static int __devexit netfront_remove(str
 	return 0;
 }
 
+
+static int open_netdev(struct netfront_info *info)
+{
+	int err;
+	
+	err = register_netdev(info->netdev);
+	if (err) {
+		printk(KERN_WARNING "%s: register_netdev err=%d\n",
+		       __FUNCTION__, err);
+		return err;
+	}
+
+	err = xennet_sysfs_addif(info->netdev);
+	if (err) {
+		/* This can be non-fatal: it only means no tuning parameters */
+		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
+		       __FUNCTION__, err);
+	}
+	return 0;
+}
 
 static void close_netdev(struct netfront_info *info)
 {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2006-08-29  7:34 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=44F3EE1F.3070308@suse.de \
    --to=kraxel@suse.de \
    --cc=kasievers@suse.de \
    --cc=xen-devel@lists.xensource.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 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.