[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5061D15F.6070408@wwwdotorg.org>
Date: Tue, 25 Sep 2012 09:44:31 -0600
From: Stephen Warren <swarren@...dotorg.org>
To: Markus Mayer <mmayer@...adcom.com>
CC: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Fix segfault in dtc when empty input file is given.
On 09/14/2012 04:23 PM, Markus Mayer wrote:
> Prior to this change, an empty input file would cause a segfault, because
> yylloc had never been initialized. There was never any characters for the
> lexer to match, so YY_USER_ACTION was never executed before the parse error
> was detected.
>
> When the parser printed the error message, it tried to include the name of
> the file, but the structure holding the file name (yylloc.file, referenced
> as pos->file) had never been initialized.
> diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
> struct boot_info *dt_from_source(const char *fname)
> {
> + extern YYLTYPE yylloc;
> +
> the_boot_info = NULL;
> treesource_error = 0;
>
> srcfile_push(fname);
> yyin = current_srcfile->f;
> + /* Initialize yylloc->file to avoid segfault on empty input */
> + srcpos_update(&yylloc, NULL, 0);
Wouldn't srcpos_update(&yyloc, fname, 0); be even more informative?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists