Commit 38f087de authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Greg Kroah-Hartman

devtmpfs: fix placement of complete() call

Calling complete() from within the __init function is wrong -
theoretically, the init process could proceed all the way to freeing
the init mem before the devtmpfsd thread gets to execute the return
instruction in devtmpfs_setup().

In practice, it seems to be harmless as gcc inlines devtmpfs_setup()
into devtmpfsd(). So the calls of the __init functions init_chdir()
etc. actually happen from devtmpfs_setup(), but the __ref on that one
silences modpost (it's all right, because those calls happen before
the complete()). But it does make the __init annotation of the setup
function moot, which we'll fix in a subsequent patch.

Fixes: bcbacc49 ("devtmpfs: refactor devtmpfsd()")
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20210312103027.2701413-1-linux@rasmusvillemoes.dkSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6b72cf12
...@@ -419,7 +419,6 @@ static int __init devtmpfs_setup(void *p) ...@@ -419,7 +419,6 @@ static int __init devtmpfs_setup(void *p)
init_chroot("."); init_chroot(".");
out: out:
*(int *)p = err; *(int *)p = err;
complete(&setup_done);
return err; return err;
} }
...@@ -432,6 +431,7 @@ static int __ref devtmpfsd(void *p) ...@@ -432,6 +431,7 @@ static int __ref devtmpfsd(void *p)
{ {
int err = devtmpfs_setup(p); int err = devtmpfs_setup(p);
complete(&setup_done);
if (err) if (err)
return err; return err;
devtmpfs_work_loop(); devtmpfs_work_loop();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment