Skip to contentSkip to conversation

Audit return code :

PATCH Superseded Christophe Lucas 2 participants 3 messages Jun 21, 2005 – Jun 22, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Audit return code :

description :
Audit return codes (and handle failure correctly) for misc_register.

drivers/misc/hdpuftrs/hdpu_cpustate.c +8 -1
diff -urpNX dontdiff 2.6.12-orig/drivers/misc/hdpuftrs/hdpu_cpustate.c 2.6.12/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -192,12 +192,19 @@ static int hdpu_cpustate_probe(struct de
 {
 	struct platform_device *pdev = to_platform_device(ddev);
 	struct resource *res;
+	int ret;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	cpustate.set_addr = (unsigned long *)res->start;
 	cpustate.clr_addr = (unsigned long *)res->end - 1;
 
-	misc_register(&cpustate_dev);
+	if (ret = misc_register(&cpustate_dev)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		cpustate.set_addr = 0;
+		cpustate.clr_addr = 0;
+		return ret ;
+	}
+
 	create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL);
 
 	printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n");

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw
Quoted 9 lines · Christophe Lucas

Audit return codes (and handle failure correctly) for misc_register.

drivers/misc/hdpuftrs/hdpu_cpustate.c +1 -0
@@ -192,12 +192,19 @@ static int hdpu_cpustate_probe(struct de
 {
 	struct platform_device *pdev = to_platform_device(ddev);
 	struct resource *res;
+	int ret;

drivers/misc/hdpuftrs/hdpu_cpustate.c static int hdpu_cpustate_probe(struct de · line 204

Quoted 10 lines
drivers/misc/hdpuftrs/hdpu_cpustate.c +4 -1
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	cpustate.set_addr = (unsigned long *)res->start;
 	cpustate.clr_addr = (unsigned long *)res->end - 1;
 
-	misc_register(&cpustate_dev);
+	if (ret = misc_register(&cpustate_dev)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		cpustate.set_addr = 0;
+		cpustate.clr_addr = 0;

Why clear them? Anyway, both are pointers, so use NULL.

drivers/misc/hdpuftrs/hdpu_cpustate.c static int hdpu_cpustate_probe(struct de · line 208

Quoted 4 lines
drivers/misc/hdpuftrs/hdpu_cpustate.c +3 -0
+		return ret ;
+	}
+
 	create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL);

Also unchecked.

Please, post patches inline.
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Christophe Lucas
Quoted 15 lines · Alexey Dobriyan
Quoted 14 lines · Christophe Lucas

Audit return codes (and handle failure correctly) for misc_register.

drivers/misc/hdpuftrs/hdpu_cpustate.c +1 -0
@@ -192,12 +192,19 @@ static int hdpu_cpustate_probe(struct de
 {
 	struct platform_device *pdev = to_platform_device(ddev);
 	struct resource *res;
+	int ret;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	cpustate.set_addr = (unsigned long *)res->start;
 	cpustate.clr_addr = (unsigned long *)res->end - 1;
 
Quoted 7 lines

drivers/misc/hdpuftrs/hdpu_cpustate.c static int hdpu_cpustate_probe(struct de · line 204

Quoted 5 lines
drivers/misc/hdpuftrs/hdpu_cpustate.c +4 -1
-	misc_register(&cpustate_dev);
+	if (ret = misc_register(&cpustate_dev)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		cpustate.set_addr = 0;
+		cpustate.clr_addr = 0;

Why clear them? Anyway, both are pointers, so use NULL.

I have cleared it as it is done in original file (line 209, 210). But I will correct it in NULL form. Thanks,

Quoted 8 lines

drivers/misc/hdpuftrs/hdpu_cpustate.c static int hdpu_cpustate_probe(struct de · line 208

Quoted 4 lines
drivers/misc/hdpuftrs/hdpu_cpustate.c +3 -0
+		return ret ;
+	}
+
 	create_proc_read_entry("sky_cpustate", 0, 0, cpustate_read_proc, NULL);

Also unchecked.

Please, post patches inline.

Ok, I will correct my configuration of mutt.

Thanks and have a nice day,

- Christophe

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors