Fixed null pointer dereference on loading e100 driver for 2.6.32.
authorFlorian Pose <fp@igh-essen.com>
Wed, 09 Nov 2011 09:55:58 +0100
changeset 2154 6a0296e7d1cd
parent 2153 5bb7df22ced2
child 2162 3f90ae16e997
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 Nov 04 13:19:03 2011 +0100
+++ 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: