]> git.baikalelectronics.ru Git - kernel.git/commit
mtd: spi-nor: Check consistency of the memory size extracted from the SFDP
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Tue, 12 Sep 2017 13:10:35 +0000 (15:10 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 18 Sep 2017 07:53:27 +0000 (09:53 +0200)
commitdf44bfd320c6157eb6eea256ac406f85aa1ba0d0
treec39be062e14d0b719e9ed49d29fcc265c4e909b0
parent384fde7ed224f283f11ef2a592b05d4a29492aa8
mtd: spi-nor: Check consistency of the memory size extracted from the SFDP

One field of the flash parameter table contains information about the
flash device size.
Most of the time the data extracted from this field is valid, but
sometimes the BFPT section of the SFDP table is corrupted or invalid and
this field is set to 0xffffffff, thus resulting in an integer overflow
when setting params->size.

Since NOR devices are anayway always smaller than 2^64 bytes, we can
easily stop the BFPT parsing if the size reported in this table is
invalid.

Fixes: 9229d5617049 ("mtd: spi-nor: parse Serial Flash Discoverable Parameters (SFDP) tables")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.com>
drivers/mtd/spi-nor/spi-nor.c