Fix root mounting with no mount options
The "trivial conversion" in commit cccaa5e335
("init: use do_mount()
instead of ksys_mount()") was totally broken, since it didn't handle the
case of a NULL mount data pointer. And while I had "tested" it (and
presumably Dominik had too) that bug was hidden by me having options.
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Reported-by: Ondřej Jirman <megi@xff.cz>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Reported-and-tested-by: Borislav Petkov <bp@suse.de>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Eric Biggers <ebiggers@kernel.org>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
d1eef1c619
commit
7de7de7ca0
|
@ -391,17 +391,19 @@ static int __init do_mount_root(const char *name, const char *fs,
|
||||||
const int flags, const void *data)
|
const int flags, const void *data)
|
||||||
{
|
{
|
||||||
struct super_block *s;
|
struct super_block *s;
|
||||||
char *data_page;
|
struct page *p = NULL;
|
||||||
struct page *p;
|
char *data_page = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* do_mount() requires a full page as fifth argument */
|
if (data) {
|
||||||
p = alloc_page(GFP_KERNEL);
|
/* do_mount() requires a full page as fifth argument */
|
||||||
if (!p)
|
p = alloc_page(GFP_KERNEL);
|
||||||
return -ENOMEM;
|
if (!p)
|
||||||
|
return -ENOMEM;
|
||||||
data_page = page_address(p);
|
data_page = page_address(p);
|
||||||
strncpy(data_page, data, PAGE_SIZE - 1);
|
/* zero-pad. do_mount() will make sure it's terminated */
|
||||||
|
strncpy(data_page, data, PAGE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
ret = do_mount(name, "/root", fs, flags, data_page);
|
ret = do_mount(name, "/root", fs, flags, data_page);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -417,7 +419,8 @@ static int __init do_mount_root(const char *name, const char *fs,
|
||||||
MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
|
MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
|
||||||
|
|
||||||
out:
|
out:
|
||||||
put_page(p);
|
if (p)
|
||||||
|
put_page(p);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue