Skip to contentSkip to conversation

misc_register : arch/x86_64/kernel/mce.c

PATCH RESEND In review Christophe Lucas 2 participants 2 messages Oct 2, 2006 – Oct 3, 2006 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 misc_register : arch/x86_64/kernel/mce.c

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

Index: linux-2.6.18/arch/x86_64/kernel/mce.c
=================================--- linux-2.6.18.orig/arch/x86_64/kernel/mce.c 2006-10-02 13:57:17.000000000 +0200
+++ linux-2.6.18/arch/x86_64/kernel/mce.c 2006-10-02 13:57:58.000000000 +0200
@@ -663,7 +663,9 @@
}

register_hotcpu_notifier(&mce_cpu_notifier);
- misc_register(&mce_log_device);
+ err = misc_register(&mce_log_device);
+ if (err < 0)
+ printk(KERN_ERR "Failed to register mce.\n");
return err;
}

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

#1 lore raw

Review

Quoted 6 lines
(quoted diff) +3 -1
-	misc_register(&mce_log_device);
+	err = misc_register(&mce_log_device);
+	if (err < 0)
+		printk(KERN_ERR "Failed to register mce.\n");
 	return err;

Failure of misc_register not necessarily means that the calling function should return an error. There are two possible cases:
1. Programmer deliberately left of misc_register return check as he thought the error is not critical. Here you may want to just print a warning message. (like arch/i386/kernel/apm.c)
2. Bug. This is where you need to return error.

Now the challenge is to differentiate between 1 & 2.

Good luck

Quoted 8 lines

}

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

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