From: Piotr JaroszyĆski
Date: Sun, 27 Mar 2011 17:26:28 +0000 (+0200)
Subject: [netdevice] Mark devices as open only if opening succeeds
X-Git-Tag: v1.20.1~2191
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ab2f51997db80c88d098844ad5a9af5736d1c9e;p=thirdparty%2Fipxe.git
[netdevice] Mark devices as open only if opening succeeds
netdev_close() assumes that devices that are open are on the
open_list, which wasn't true if device specific opening failed.
Signed-off-by: Michael Brown
---
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 813823760..301738173 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -463,13 +463,13 @@ int netdev_open ( struct net_device *netdev ) {
DBGC ( netdev, "NETDEV %s opening\n", netdev->name );
- /* Mark as opened */
- netdev->state |= NETDEV_OPEN;
-
/* Open the device */
if ( ( rc = netdev->op->open ( netdev ) ) != 0 )
return rc;
+ /* Mark as opened */
+ netdev->state |= NETDEV_OPEN;
+
/* Add to head of open devices list */
list_add ( &netdev->open_list, &open_net_devices );