mtdblock read sector and cache_data == NULL
Hey,
I think the cache_data buffer is used uninitialized in case no write prepends the first read.
Initialization of cache_data buffer:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n300
--------------------
if (!(mbd->mtd->flags & MTD_NO_ERASE) && mbd->mtd->erasesize) {
mtdblk->cache_size = mbd->mtd->erasesize;
mtdblk->cache_data = NULL;
}----------------
And later in do_cached_read it is just used with mtdblock->cache_data + offset.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n243
The only allocation I can find is in writesector function, so I figured that the mtd_read will get NULL+offset in the first read.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n272
Is it correct to place the same if unlikely stuff in the mtdblock_readsect function like in the mtdblock_writesect one?
Greetings
Thilo
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
hey,
forget it :) ... I got confused ....
Greetings Thilo
Quoted 29 lines · Cestonaro Thilo
Hey,
I think the
cache_databuffer is used uninitialized in case no write prepends the first read.Initialization of
cache_databuffer:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n300
--------------------if (!(mbd->mtd->flags & MTD_NO_ERASE) && mbd->mtd->erasesize) { mtdblk->cache_size = mbd->mtd->erasesize; mtdblk->cache_data = NULL; }----------------
And later in
do_cached_readit is just used withmtdblock->cache_data+ offset.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n243The only allocation I can find is in writesector function, so I figured that the
mtd_readwill get NULL+offset in the first read.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/mtd/mtdblock.c?id=refs/tags/v3.14-rc2#n272Is it correct to place the same if unlikely stuff in the
mtdblock_readsectfunction like in themtdblock_writesectone?Greetings
Thilo
Signature · 21 lines
With best regards Thilo Cestonaro FTS PBG PDG WPS R&D EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html