]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/mtd/mtdblock.c
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[mv-sheeva.git] / drivers / mtd / mtdblock.c
index af6591237b9b51f22022e61a653fa7a5d8e29845..6c6d80736fadfb4013871b31795e17354a4d671e 100644 (file)
@@ -321,8 +321,12 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
        mutex_unlock(&mtdblk->cache_mutex);
 
        if (!--mtdblk->count) {
-               /* It was the last usage. Free the cache */
-               mtd_sync(mbd->mtd);
+               /*
+                * It was the last usage. Free the cache, but only sync if
+                * opened for writing.
+                */
+               if (mbd->file_mode & FMODE_WRITE)
+                       mtd_sync(mbd->mtd);
                vfree(mtdblk->cache_data);
        }