Re: [patch] module: potential deadlock in error path

From: Linus Torvalds
Date: Sun Jan 20 2013 - 20:56:20 EST


On Sun, Jan 20, 2013 at 5:20 PM, Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> writes:
>> We take the lock twice if we hit this goto.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>
> Damn, just pushed that to Linus: should have read mail first.
>
> I've added this, thanks.

I'm not pulling this. It seems stupid.

Why isn't the fix just this (whitespace-damaged, cut-and-pasted)
one-liner instead? I may be blind, but as far as I cal tell, there's
exactly one single place we do that "giti ddebug_cleanup", and it
wants to unlock the mutex, so we should just move the unlock down one
line instead.

Hmm? Is there some hidden magic going on that I can't see?

Linus

---
diff --git a/kernel/module.c b/kernel/module.c
index d25e359279ae..eab08274ec9b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3274,8 +3274,8 @@ again:
/* module_bug_cleanup needs module_mutex protection */
mutex_lock(&module_mutex);
module_bug_cleanup(mod);
- mutex_unlock(&module_mutex);
ddebug_cleanup:
+ mutex_unlock(&module_mutex);
dynamic_debug_remove(info->debug);
synchronize_sched();
kfree(mod->args);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/