[Cbe-oss-dev] [PATCH] spufs: fix missing error handling in module_init()

Akinobu Mita mita at fixstars.com
Wed Mar 14 13:57:16 EST 2007


spufs module_init forgot to call a few cleanup functions
on error path. This patch also includes cosmetic changes in
spu_sched_init() (identation fix and return error code).

Cc: Arnd Bergmann <arnd at arndb.de>
Signed-off-by: Akinobu Mita <mita at fixstars.com>

---
 arch/powerpc/platforms/cell/spufs/inode.c |   16 ++++++++++------
 arch/powerpc/platforms/cell/spufs/sched.c |    6 +++---
 2 files changed, 13 insertions(+), 9 deletions(-)

Index: 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/sched.c
===================================================================
--- 2.6-git-ps3.orig/arch/powerpc/platforms/cell/spufs/sched.c
+++ 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/sched.c
@@ -474,14 +474,14 @@ int __init spu_sched_init(void)
 
 	spu_sched_wq = create_singlethread_workqueue("spusched");
 	if (!spu_sched_wq)
-		return 1;
+		return -ENOMEM;
 
 	spu_prio = kzalloc(sizeof(struct spu_prio_array), GFP_KERNEL);
 	if (!spu_prio) {
 		printk(KERN_WARNING "%s: Unable to allocate priority queue.\n",
 		       __FUNCTION__);
-		       destroy_workqueue(spu_sched_wq);
-		return 1;
+		destroy_workqueue(spu_sched_wq);
+		return -ENOMEM;
 	}
 	for (i = 0; i < MAX_PRIO; i++) {
 		INIT_LIST_HEAD(&spu_prio->runq[i]);
Index: 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/inode.c
===================================================================
--- 2.6-git-ps3.orig/arch/powerpc/platforms/cell/spufs/inode.c
+++ 2.6-git-ps3/arch/powerpc/platforms/cell/spufs/inode.c
@@ -660,25 +660,29 @@ static int __init spufs_init(void)
 
 	if (!spufs_inode_cache)
 		goto out;
-	if (spu_sched_init() != 0) {
-		kmem_cache_destroy(spufs_inode_cache);
-		goto out;
-	}
-	ret = register_filesystem(&spufs_type);
+	ret = spu_sched_init();
 	if (ret)
 		goto out_cache;
+	ret = register_filesystem(&spufs_type);
+	if (ret)
+		goto out_sched;
 	ret = register_spu_syscalls(&spufs_calls);
 	if (ret)
 		goto out_fs;
 	ret = register_arch_coredump_calls(&spufs_coredump_calls);
 	if (ret)
-		goto out_fs;
+		goto out_syscalls;
 
 	spufs_init_isolated_loader();
 
 	return 0;
+
+out_syscalls:
+	unregister_spu_syscalls(&spufs_calls);
 out_fs:
 	unregister_filesystem(&spufs_type);
+out_sched:
+	spu_sched_exit();
 out_cache:
 	kmem_cache_destroy(spufs_inode_cache);
 out:



More information about the cbe-oss-dev mailing list