Browse files

Fix a bug in flashcache_writeback_load(), where a bad argument is bei…

…ng passed into vmalloc().

Summary: The vmalloc() for the superblock in flashcache_writeback_load() is passed a bad
size argument. Thanks to Ping Huang for spotting this and reporting it.

Test Plan:

Reviewers:

CC:

Task ID: #

Blame Rev:
  • Loading branch information...
1 parent b62da36 commit c4bddf620cb072d5d33e784bf9717bb05fe71fa8 Mohan Srinivasan committed Oct 25, 2012
Showing with 6 additions and 5 deletions.
  1. +5 −4 src/flashcache.h
  2. +1 −1 src/flashcache_conf.c
View
9 src/flashcache.h
@@ -86,10 +86,11 @@
#define FLASHCACHE_COPY_PAGES (1024)
/* Default cache parameters */
-#define DEFAULT_CACHE_SIZE 65536
-#define DEFAULT_CACHE_ASSOC 512
-#define DEFAULT_BLOCK_SIZE 8 /* 4 KB */
-#define DEFAULT_MD_BLOCK_SIZE 8 /* 4 KB */
+#define DEFAULT_CACHE_SIZE 65536
+#define DEFAULT_CACHE_ASSOC 512
+#define DEFAULT_BLOCK_SIZE 8 /* 4 KB */
+#define DEFAULT_MD_BLOCK_SIZE 8 /* 4 KB */
+#define DEFAULT_MD_BLOCK_SIZE_BYTES (DEFAULT_MD_BLOCK_SIZE * 512) /* 4 KB */
#define FLASHCACHE_MAX_MD_BLOCK_SIZE 128 /* 64 KB */
#define FLASHCACHE_FIFO 0
View
2 src/flashcache_conf.c
@@ -589,7 +589,7 @@ flashcache_writeback_load(struct cache_c *dmc)
* We don't know what the preferred block size is, just read off
* the default md blocksize.
*/
- header = (struct flash_superblock *)vmalloc(DEFAULT_MD_BLOCK_SIZE);
+ header = (struct flash_superblock *)vmalloc(DEFAULT_MD_BLOCK_SIZE_BYTES);
if (!header) {
DMERR("flashcache_writeback_load: Unable to allocate memory");
return 1;

0 comments on commit c4bddf6

Please sign in to comment.