From 2bf0922e80b35c79fcc56318e71b1da29f55df0c Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Wed, 5 Feb 2014 17:21:37 -0500 Subject: core: Avoid initializing the cache more than once Most of file system drivers initialize the cache themselves. The problem is that the same cache could be again initialized later, then invalidating the previous one. This patch fixes this. Problem found while auditing the code. Signed-off-by: Raphael S. Carvalho --- core/fs/fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/fs/fs.c') diff --git a/core/fs/fs.c b/core/fs/fs.c index 6965d1da..0846c887 100644 --- a/core/fs/fs.c +++ b/core/fs/fs.c @@ -430,8 +430,9 @@ void fs_init(const struct fs_ops **ops, void *priv) } this_fs = &fs; - /* initialize the cache */ - if (fs.fs_dev && fs.fs_dev->cache_data) + /* initialize the cache only if it wasn't already initialized + * by the fs driver */ + if (fs.fs_dev && fs.fs_dev->cache_data && !fs.fs_dev->cache_init) cache_init(fs.fs_dev, blk_shift); /* start out in the root directory */ -- cgit v1.2.1