patch-2.4.21 linux-2.4.21/drivers/sbus/char/envctrl.c

Next file: linux-2.4.21/drivers/scsi/3w-xxxx.c
Previous file: linux-2.4.21/drivers/sbus/char/display7seg.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/sbus/char/envctrl.c linux-2.4.21/drivers/sbus/char/envctrl.c
@@ -1050,7 +1050,7 @@
 	struct linux_ebus *ebus = NULL;
 	struct linux_ebus_device *edev = NULL;
 	struct linux_ebus_child *edev_child = NULL;
-	int i = 0;
+	int err, i = 0;
 
 	for_each_ebus(ebus) {
 		for_each_ebusdev(edev, ebus) {
@@ -1105,9 +1105,11 @@
 	udelay(200);
 
 	/* Register the device as a minor miscellaneous device. */
-	if (misc_register(&envctrl_dev)) {
+	err = misc_register(&envctrl_dev);
+	if (err) {
 		printk("envctrl: Unable to get misc minor %d\n",
 		       envctrl_dev.minor);
+		goto out_iounmap;
 	}
 
 	/* Note above traversal routine post-incremented 'i' to accomodate 
@@ -1122,9 +1124,21 @@
 			i2c_childlist[i].addr, (0 == i) ? ("\n") : (" "));
 	}
 
-	kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES);
+	err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES);
+	if (err)
+		goto out_deregister;
 
 	return 0;
+
+out_deregister:
+	misc_deregister(&envctrl_dev);
+out_iounmap:
+	iounmap(i2c);
+	for (i = 0; i < ENVCTRL_MAX_CPU * 2; i++) {
+		if (i2c_childlist[i].tables)
+			kfree(i2c_childlist[i].tables);
+	}
+	return err;
 #else
 	return -ENODEV;
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)