[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkaQJrXt3y_QDyZpQpeJqB0nYsV_p21h63SS1k2Q3Da=w@mail.gmail.com>
Date: Fri, 7 Feb 2020 00:04:31 +0000
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Jian Cai <caij2003@...il.com>
Cc: alsa-devel@...a-project.org, Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] ASoC: soc-core: fix an uninitialized use
On Fri, Feb 7, 2020 at 12:55 AM Jian Cai <caij2003@...il.com> wrote:
>
> Hi Nick,
>
> 'ret' is only defined in if branches and for loops (e.g. for_each_component_dais). If none of these branches or loops get executed, then eventually we end up having
https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-core.c#L1276
and
https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-core.c#L1287
both assign to `ret` before any `goto` is taken. Are you perhaps
looking at an older branch of the LTS tree, but not the master branch
of the mainline tree? (Or it's possible that it's 1am here in Zurich,
and I should go to bed).
>
> int ret;
>
> err_probe:
> if (ret < 0)
> soc_cleanup_component(component);
>
> With -ftrivial-auto-var-init=pattern, this code becomes
>
> int ret;
>
> err_probe:
> ret = 0xAAAAAAAA;
> if (ret < 0)
> soc_cleanup_component(component);
>
> So soc_cleanup_component gets called unintentionally this case, which causes the built kernel to miss some files.
>
>
>
> On Thu, Feb 6, 2020 at 3:28 PM Nick Desaulniers <ndesaulniers@...gle.com> wrote:
>>
>> > Fixed the uninitialized use of a signed integer variable ret in
>> > soc_probe_component when all its definitions are not executed. This
>> > caused -ftrivial-auto-var-init=pattern to initialize the variable to
>> > repeated 0xAA (i.e. a negative value) and triggered the following code
>> > unintentionally.
>>
>> > Signed-off-by: Jian Cai <caij2003@...il.com>
>>
>> Hi Jian,
>> I don't quite follow; it looks like `ret` is assigned to multiple times in
>> `soc_probe_component`. Are one of the return values of one of the functions
>> that are called then assigned to `ret` undefined? What control flow path leaves
>> `ret` unitialized?
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists