Fixed null pointer dereference on loading e100 driver for 2.6.32. redundancy
authorFlorian Pose <fp@igh-essen.com>
Wed, 09 Nov 2011 09:55:58 +0100
branchredundancy
changeset 2142 26c74f035ab0
parent 2137 bb9af8815750
child 2156 71425e6120d8
Fixed null pointer dereference on loading e100 driver for 2.6.32.
devices/e100-2.6.32-ethercat.c
--- a/devices/e100-2.6.32-ethercat.c	Fri Oct 28 17:06:04 2011 +0200
+++ b/devices/e100-2.6.32-ethercat.c	Wed Nov 09 09:55:58 2011 +0100
@@ -2984,18 +2984,15 @@
 
 	// offer device to EtherCAT master module
 	nic->ecdev = ecdev_offer(netdev, e100_ec_poll, THIS_MODULE);
-	if (nic->ecdev) {
-		if (ecdev_open(nic->ecdev)) {
-			ecdev_withdraw(nic->ecdev);
-			goto err_out_free;
-		}
-	} else {
+
+	if (!nic->ecdev) {
 		strcpy(netdev->name, "eth%d");
 		if((err = register_netdev(netdev))) {
 			DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n");
 			goto err_out_free;
 		}
 	}
+
 	nic->cbs_pool = pci_pool_create(netdev->name,
 			   nic->pdev,
 			   nic->params.cbs.count * sizeof(struct cb),
@@ -3005,6 +3002,13 @@
 		(unsigned long long)pci_resource_start(pdev, use_io ? 1 : 0),
 		pdev->irq, netdev->dev_addr);
 
+	if (nic->ecdev) {
+		if (ecdev_open(nic->ecdev)) {
+			ecdev_withdraw(nic->ecdev);
+			goto err_out_free;
+		}
+	}
+
 	return 0;
 
 err_out_free: