[PATCH 1/6] aoe: initialize error message synchronization before registration

From: Jiale Yao

Date: Wed Oct 28 2026 - 00:48:58 EST


register_chrdev() makes the AoE character device available before the
error message completion and lock are initialized. A userspace access
racing module initialization can therefore use either object before it
is ready.

Initialize both synchronization objects before registering the character
device.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/block/aoe/aoechr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index a42c4bcc85ba..efc09c97ff23 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -288,13 +288,14 @@ aoechr_init(void)
{
int n, i;

+ init_completion(&emsgs_comp);
+ spin_lock_init(&emsgs_lock);
+
n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
if (n < 0) {
printk(KERN_ERR "aoe: can't register char device\n");
return n;
}
- init_completion(&emsgs_comp);
- spin_lock_init(&emsgs_lock);
n = class_register(&aoe_class);
if (n) {
unregister_chrdev(AOE_MAJOR, "aoechr");
@@ -319,4 +320,3 @@ aoechr_exit(void)
class_unregister(&aoe_class);
unregister_chrdev(AOE_MAJOR, "aoechr");
}
-
--
2.34.1