From: Cestonaro Thilo <thilo.cestonaro-RJz4owOZxyXQFUHtdCDX3A@public.gmane.org>
To: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: mtdblock read sector and cache_data == NULL
Date: Tue, 11 Feb 2014 09:36:31 +0100 [thread overview]
Message-ID: <52F9E10F.8060904@ts.fujitsu.com> (raw)
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
next reply other threads:[~2014-02-11 8:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-11 8:36 Cestonaro Thilo [this message]
[not found] ` <52F9E10F.8060904-RJz4owOZxyXQFUHtdCDX3A@public.gmane.org>
2014-02-11 8:46 ` mtdblock read sector and cache_data == NULL Cestonaro Thilo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52F9E10F.8060904@ts.fujitsu.com \
--to=thilo.cestonaro-rjz4owozxyxqfuhtdcdx3a@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).