Skip to content

Commit

Permalink
devtmpfs: fix placement of complete() call
Browse files Browse the repository at this point in the history
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: bcbacc4 ("devtmpfs: refactor devtmpfsd()")
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Rasmus Villemoes <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Villemoes authored and gregkh committed Mar 23, 2021
1 parent 6b72cf1 commit 38f087d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ static int __init devtmpfs_setup(void *p)
init_chroot(".");
out:
*(int *)p = err;
complete(&setup_done);
return err;
}

Expand All @@ -432,6 +431,7 @@ static int __ref devtmpfsd(void *p)
{
int err = devtmpfs_setup(p);

complete(&setup_done);
if (err)
return err;
devtmpfs_work_loop();
Expand Down

0 comments on commit 38f087d

Please sign in to comment.