[PATCH] fs: check pointer returned by get_fsdevice_by_path before dereferencing

Gaël PORTAY gael.portay at savoirfairelinux.com
Mon Mar 19 02:06:17 PDT 2018


Hi Sascha,

On Mon, Mar 19, 2018 at 09:36:29AM +0100, Sascha Hauer wrote:
> ...
> I wonder though what calls into the filesystem layer before / is
> mounted in your case.
>

The issue is trigger by function stat() in start_barebox(), right before
I expect to have a shell.

Here.

	if (IS_ENABLED(CONFIG_COMMAND_SUPPORT)) {
		pr_info("running /env/bin/init...\n");

		if (!stat("/env/bin/init", &s))
			run_command("source /env/bin/init");
		else
			pr_err("/env/bin/init not found\n");
	}

My configuration is very minimal for now. I do not have (yet) any FS
selected (excepted devfs) and I do not have any root device mounted
either in this configuration.

I guess this is why fs_dev_root is NULL and why get_fsdevice_by_path()
returns fs_dev_root (because there is nothing to iterate in list
fs_device_list).

Gael



More information about the barebox mailing list