Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] hdpu_cpustate.c: misc_register() can fail

Signed-off-by: Christophe Lucas <clucas@rotomalug.org>
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Christophe Lucas and committed by
Linus Torvalds
1ac19f4c cf85d5ca

+19 -4
+19 -4
drivers/misc/hdpuftrs/hdpu_cpustate.c
··· 192 192 { 193 193 struct platform_device *pdev = to_platform_device(ddev); 194 194 struct resource *res; 195 + struct proc_dir_entry *proc_de; 196 + int ret; 195 197 196 198 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 197 199 cpustate.set_addr = (unsigned long *)res->start; 198 200 cpustate.clr_addr = (unsigned long *)res->end - 1; 199 201 200 - misc_register(&cpustate_dev); 201 - create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL); 202 + ret = misc_register(&cpustate_dev); 203 + if (ret) { 204 + printk(KERN_WARNING "sky_cpustate: Unable to register misc " 205 + "device.\n"); 206 + cpustate.set_addr = NULL; 207 + cpustate.clr_addr = NULL; 208 + return ret; 209 + } 210 + 211 + proc_de = create_proc_read_entry("sky_cpustate", 0, 0, 212 + cpustate_read_proc, NULL); 213 + if (proc_de == NULL) 214 + printk(KERN_WARNING "sky_cpustate: Unable to create proc " 215 + "dir entry\n"); 202 216 203 217 printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n"); 204 218 return 0; 205 219 } 220 + 206 221 static int hdpu_cpustate_remove(struct device *ddev) 207 222 { 208 223 209 - cpustate.set_addr = 0; 210 - cpustate.clr_addr = 0; 224 + cpustate.set_addr = NULL; 225 + cpustate.clr_addr = NULL; 211 226 212 227 remove_proc_entry("sky_cpustate", NULL); 213 228 misc_deregister(&cpustate_dev);