[PATCH] UBI: Fix crash in try_recover_peb()
Geert Uytterhoeven
geert at linux-m68k.org
Mon Oct 17 01:00:39 PDT 2016
Hi Boris,
On Fri, Oct 14, 2016 at 12:49 PM, Boris Brezillon
<boris.brezillon at free-electrons.com> wrote:
> On Thu, 13 Oct 2016 16:24:58 +0200
> Boris Brezillon <boris.brezillon at free-electrons.com> wrote:
>> On Thu, 13 Oct 2016 16:05:36 +0200
>> Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>>
>> > drivers/mtd/ubi/eba.c: In function ‘try_recover_peb’:
>> > drivers/mtd/ubi/eba.c:744: warning: ‘vid_hdr’ is used uninitialized in this function
>> >
>> > The pointer vid_hdr is indeed not initialized, leading to a crash when
>> > it is dereferenced.
>> >
>> > Fix this by obtaining the pointer from the VID buffer, like is done
>> > everywhere else.
>>
>> Indeed, I don't know how I missed that one :-/.
>
> That's really weird. I tried to recompile the kernel on my machine
> (before applying your patch), to see if the compiler was complaining,
> and it's not :-(.
>
> I also coded simple functions with goto statements, to check that the
> detection was working correctly, and it is.
>
> Maybe you have some ideas why my compiler is failing to detect the
> problem (I'm currently using the ubuntu cross-toolchain:
> 'arm-linux-gnueabi-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.1) 5.4.0
> 20160609').
It depends highly on the toolchain.
My good old m68k-linux-gnu-gcc version 4.1.2 20061115 (prerelease) (Ubuntu
4.1.1-21) is known to generate plenty of warnings like these. Due to the high
percentage of false positives, this was disabled in later versions of gcc, but
(partially) re-enabled later (usually Arnd catches most of these while stll in
-next. I'm afraid he's suffering from travelling to Linaro Connect ;-)
Still, some of them are real bugs, so that's when my patch habits kick in...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
More information about the linux-mtd
mailing list