linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mtdblock read sector and cache_data == NULL
@ 2014-02-11  8:36 Cestonaro Thilo
       [not found] ` <52F9E10F.8060904-RJz4owOZxyXQFUHtdCDX3A@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Cestonaro Thilo @ 2014-02-11  8:36 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA

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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-11  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-11  8:36 mtdblock read sector and cache_data == NULL Cestonaro Thilo
     [not found] ` <52F9E10F.8060904-RJz4owOZxyXQFUHtdCDX3A@public.gmane.org>
2014-02-11  8:46   ` Cestonaro Thilo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).