Skip to contentSkip to conversation

Audit return code : drivers/char/applicom.c

PATCH In review Christophe Lucas 4 participants 10 messages Jun 21, 2005 – Jun 22, 2005

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

PATCH 1/1 Audit return code : drivers/char/applicom.c

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

drivers/char/applicom.c +18 -4
diff -urpNX dontdiff 2.6.12-orig/drivers/char/applicom.c 2.6.12/drivers/char/applicom.c
@@ -172,7 +172,7 @@ static int ac_register_board(unsigned lo
 
 void cleanup_module(void)
 {
-	int i;
+	unsigned int i;
 
 	misc_deregister(&ac_miscdev);
 
@@ -195,7 +195,7 @@ int __init applicom_init(void)
 	int i, numisa = 0;
 	struct pci_dev *dev = NULL;
 	void __iomem *RamIO;
-	int boardno;
+	int boardno, ret;
 
 	printk(KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n");
 
@@ -294,7 +294,7 @@ int __init applicom_init(void)
 	}
 
 	if (!numisa)
-		printk(KERN_WARNING"ac.o: No valid ISA Applicom boards found at mem 0x%lx\n",mem);
+		printk(KERN_WARNING "ac.o: No valid ISA Applicom boards found at mem 0x%lx\n",mem);
 
  fin:
 	init_waitqueue_head(&FlagSleepRec);
@@ -304,7 +304,10 @@ int __init applicom_init(void)
 	DeviceErrorCount = 0;
 
 	if (numboards) {
-		misc_register(&ac_miscdev);
+		if (ret = misc_register(&ac_miscdev)) {
+			printk(KERN_WARNING "Unable to register misc device\n");
+			goto out;
+		}
 		for (i = 0; i < MAX_BOARD; i++) {
 			int serial;
 			char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1];
@@ -337,6 +340,17 @@ int __init applicom_init(void)
 
 	else
 		return -ENXIO;
+
+out:
+	for (i = 0 ; i < MAX_BOARD ; i++) {
+		if (apbs[i].RamIO)
+			continue;
+		if (apbs[i].irq)
+			free_irq(apbs[i].irq, &dummy);
+		iounmap(apbs[i].RamIO);
+	}
+	pci_disable_device(dev);
+	return ret ;
 }
 
 

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

#1 lore raw

PATCH 1/1 Audit return code : drivers/char/lcd.c

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

drivers/char/lcd.c +5 -1
diff -urpNX dontdiff 2.6.12-orig/drivers/char/lcd.c 2.6.12/drivers/char/lcd.c
@@ -613,10 +613,14 @@ static struct miscdevice lcd_dev = {
 
 static int lcd_init(void)
 {
+	int ret ;
 	unsigned long data;
 
 	pr_info("%s\n", LCD_DRIVER);
-	misc_register(&lcd_dev);
+	if (ret = misc_register(&lcd_dev)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		return ret ;
+	}
 
 	/* Check region? Naaah! Just snarf it up. */
 /*	request_region(RTC_PORT(0), RTC_IO_EXTENT, "lcd");*/

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

#2 lore raw

PATCH 1/1 Audit return code : drivers/input/misc/hp_sdc_rtc.c

In reply to Christophe Lucas

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

drivers/input/misc/hp_sdc_rtc.c +4 -1
diff -urpNX dontdiff 2.6.12-orig/drivers/input/misc/hp_sdc_rtc.c 2.6.12/drivers/input/misc/hp_sdc_rtc.c
@@ -702,7 +702,10 @@ static int __init hp_sdc_rtc_init(void)
 
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
-	misc_register(&hp_sdc_rtc_dev);
+	if (ret = misc_register(&hp_sdc_rtc_dev)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		return ret ;
+	}
         create_proc_read_entry ("driver/rtc", 0, 0, 
 				hp_sdc_rtc_read_proc, NULL);
 

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

#3 lore raw

PATCH 1/1 Audit return code : drivers/macintosh/apm_emu.c

In reply to Christophe Lucas

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

drivers/macintosh/apm_emu.c +6 -2
diff -urpNX dontdiff 2.6.12-orig/drivers/macintosh/apm_emu.c 2.6.12/drivers/macintosh/apm_emu.c
@@ -515,6 +515,7 @@ static struct miscdevice apm_device = {
 
 static int __init apm_emu_init(void)
 {
+	int ret ;
 	struct proc_dir_entry *apm_proc;
 
 	if (sys_ctrler != SYS_CTRLER_PMU) {
@@ -522,12 +523,15 @@ static int __init apm_emu_init(void)
 		return -ENODEV;
 	}
 		
+	if (ret = misc_register(&apm_device)) {
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		return ret ;
+	}
+
 	apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info);
 	if (apm_proc)
 		apm_proc->owner = THIS_MODULE;
 
-	misc_register(&apm_device);
-
 	pmu_register_sleep_notifier(&apm_sleep_notifier);
 
 	printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version);

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

#4 lore raw

Re: [KJ] [PATCH] Audit return code : drivers/input/misc/hp_sdc_rtc.c

In reply to Christophe Lucas

drivers/input/misc/hp_sdc_rtc.c static int __init hp_sdc_rtc_init(void) · line 705

Quoted 10 lines · Christophe Lucas

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

drivers/input/misc/hp_sdc_rtc.c +1 -1
@@ -702,7 +702,10 @@ static int __init hp_sdc_rtc_init(void)
 
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
-	misc_register(&hp_sdc_rtc_dev);
+	if (ret = misc_register(&hp_sdc_rtc_dev)) {

hp_sdc_request_timer_irq() have hp_sdc_release_timer_irq() counterpart. Double brackets, please. Otherwise gcc will warn. Ditto for other patches.

drivers/input/misc/hp_sdc_rtc.c static int __init hp_sdc_rtc_init(void) · line 707

Quoted 2 lines
drivers/input/misc/hp_sdc_rtc.c +2 -0
+		printk(KERN_WARNING "Unable to register misc device.\n");
+		return ret ;

And don't add space. Ditto for other patches.
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw
In reply to Christophe Lucas

On Tue, 21 Jun 2005 12:13:13 +0200 Christophe Lucas wrote:

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

drivers/char/applicom.c +1 -1
diff -urpNX dontdiff 2.6.12-orig/drivers/char/applicom.c 2.6.12/drivers/char/applicom.c
@@ -172,7 +172,7 @@ static int ac_register_board(unsigned lo
 
 void cleanup_module(void)
 {
-	int i;
+	unsigned int i;
 

what is the purpose of this change? no description for it.

+ return ret ;

what Alexey said...

---
~Randy

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

#6 lore raw
In reply to Christophe Lucas
Quoted 10 lines · randy_dunlap

On Tue, 21 Jun 2005 12:13:13 +0200 Christophe Lucas wrote:

drivers/char/applicom.c +1 -1
 
 void cleanup_module(void)
 {
-	int i;
+	unsigned int i;

what is the purpose of this change? no description for it.

IIRC, gcc 4 sez something about comparing signed and unsigned blah blah, despite

	int i;
	for (i = 0; i < N; i++)

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

#7 lore raw
In reply to Christophe Lucas

On Tue, 21 Jun 2005 23:42:47 +0400 Alexey Dobriyan wrote:

| On Tuesday 21 June 2005 23:30, randy_dunlap wrote:
| > On Tue, 21 Jun 2005 12:13:13 +0200 Christophe Lucas wrote:
| > --- 2.6.12-orig/drivers/char/applicom.c
| > +++ 2.6.12/drivers/char/applicom.c
| 
| >  void cleanup_module(void)
| >  {
| > -	int i;
| > +	unsigned int i;
| > 
| > what is the purpose of this change?  no description for it.
| 
| IIRC, gcc 4 sez something about comparing signed and unsigned blah blah, despite
| 
| 	int i;
| 	for (i = 0; i < N; i++)
| 
| being standard C idiom.

I suspected that was the case (problem), but the patch description should say something about that...

---
~Randy

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

#8 lore raw

Re: [KJ] [PATCH] Audit return code : drivers/input/misc/hp_sdc_rtc.c

In reply to Christophe Lucas
Quoted 7 lines · Alexey Dobriyan
Quoted 6 lines · Christophe Lucas

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

drivers/input/misc/hp_sdc_rtc.c +0 -0
@@ -702,7 +702,10 @@ static int __init hp_sdc_rtc_init(void)
 
Quoted 7 lines

drivers/input/misc/hp_sdc_rtc.c static int __init hp_sdc_rtc_init(void) · line 705

Quoted 4 lines
drivers/input/misc/hp_sdc_rtc.c +1 -1
 	if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
 		return ret;
-	misc_register(&hp_sdc_rtc_dev);
+	if (ret = misc_register(&hp_sdc_rtc_dev)) {

hp_sdc_request_timer_irq() have hp_sdc_release_timer_irq() counterpart. Double brackets, please. Otherwise gcc will warn. Ditto for other patches.

In fact, don't do an assignment inside an if. Ever.

	ret = misc_register(&hp_sdc_rtc_dev);
	if (ret) ...

is much clearer.

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

#9 lore raw
In reply to Christophe Lucas
Quoted 21 lines · randy_dunlap

On Tue, 21 Jun 2005 23:42:47 +0400 Alexey Dobriyan wrote:

| On Tuesday 21 June 2005 23:30, randy_dunlap wrote:
| > On Tue, 21 Jun 2005 12:13:13 +0200 Christophe Lucas wrote:
| > --- 2.6.12-orig/drivers/char/applicom.c
| > +++ 2.6.12/drivers/char/applicom.c
| 
| >  void cleanup_module(void)
| >  {
| > -	int i;
| > +	unsigned int i;
| > 
| > what is the purpose of this change?  no description for it.
| 
| IIRC, gcc 4 sez something about comparing signed and unsigned blah blah, despite
| 
| 	int i;
| 	for (i = 0; i < N; i++)
| 
| being standard C idiom.
Quoted 2 lines

I suspected that was the case (problem), but the patch description should say something about that...

Hi,

Sorry, s/int i/unsigned int i/ is as said by Alexey one entry in kj TODO. I will resend patch with correct description, put retval assignment out if if() statement.

Thanks for all your good advise.

- Christophe

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