prominfo_proc fixes
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 1 Apr 2013 02:50:16 +0000 (22:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 9 Apr 2013 18:13:34 +0000 (14:13 -0400)
* check for proc_mkdir() failures
* use remove_proc_subtree()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/ia64/sn/kernel/sn2/prominfo_proc.c

index 20b88cb1881a93e87b57d4d7b3e04e0c907eaa74..90298bda936aff48f3a96d1a7dc2db28334d257b 100644 (file)
@@ -216,58 +216,40 @@ void __exit prominfo_exit(void);
 module_init(prominfo_init);
 module_exit(prominfo_exit);
 
-static struct proc_dir_entry **proc_entries;
 static struct proc_dir_entry *sgi_prominfo_entry;
 
 #define NODE_NAME_LEN 11
 
 int __init prominfo_init(void)
 {
-       struct proc_dir_entry **entp;
        cnodeid_t cnodeid;
-       unsigned long nasid;
-       int size;
-       char name[NODE_NAME_LEN];
 
        if (!ia64_platform_is("sn2"))
                return 0;
 
-       size = num_online_nodes() * sizeof(struct proc_dir_entry *);
-       proc_entries = kzalloc(size, GFP_KERNEL);
-       if (!proc_entries)
-               return -ENOMEM;
-
        sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL);
+       if (!sgi_prominfo_entry)
+               return -ENOMEM;
 
-       entp = proc_entries;
        for_each_online_node(cnodeid) {
+               struct proc_dir_entry *dir;
+               unsigned long nasid;
+               char name[NODE_NAME_LEN];
+
                sprintf(name, "node%d", cnodeid);
-               *entp = proc_mkdir(name, sgi_prominfo_entry);
+               dir = proc_mkdir(name, sgi_prominfo_entry);
+               if (!dir)
+                       continue;
                nasid = cnodeid_to_nasid(cnodeid);
-               create_proc_read_entry("fit", 0, *entp, read_fit_entry,
+               create_proc_read_entry("fit", 0, dir, read_fit_entry,
                                           (void *)nasid);
-               create_proc_read_entry("version", 0, *entp,
+               create_proc_read_entry("version", 0, dir,
                                           read_version_entry, (void *)nasid);
-               entp++;
        }
-
        return 0;
 }
 
 void __exit prominfo_exit(void)
 {
-       struct proc_dir_entry **entp;
-       unsigned int cnodeid;
-       char name[NODE_NAME_LEN];
-
-       entp = proc_entries;
-       for_each_online_node(cnodeid) {
-               remove_proc_entry("fit", *entp);
-               remove_proc_entry("version", *entp);
-               sprintf(name, "node%d", cnodeid);
-               remove_proc_entry(name, sgi_prominfo_entry);
-               entp++;
-       }
-       remove_proc_entry("sgi_prominfo", NULL);
-       kfree(proc_entries);
+       remove_proc_subtree("sgi_prominfo", NULL);
 }