Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Fix a bug in flashcache_writeback_load(), where a bad argument is bei…
Browse files Browse the repository at this point in the history
…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
Mohan Srinivasan committed Oct 25, 2012
1 parent b62da36 commit c4bddf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/flashcache.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@
#define FLASHCACHE_COPY_PAGES (1024) #define FLASHCACHE_COPY_PAGES (1024)


/* Default cache parameters */ /* Default cache parameters */
#define DEFAULT_CACHE_SIZE 65536 #define DEFAULT_CACHE_SIZE 65536
#define DEFAULT_CACHE_ASSOC 512 #define DEFAULT_CACHE_ASSOC 512
#define DEFAULT_BLOCK_SIZE 8 /* 4 KB */ #define DEFAULT_BLOCK_SIZE 8 /* 4 KB */
#define DEFAULT_MD_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_MAX_MD_BLOCK_SIZE 128 /* 64 KB */


#define FLASHCACHE_FIFO 0 #define FLASHCACHE_FIFO 0
Expand Down
2 changes: 1 addition & 1 deletion src/flashcache_conf.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ flashcache_writeback_load(struct cache_c *dmc)
* We don't know what the preferred block size is, just read off * We don't know what the preferred block size is, just read off
* the default md blocksize. * 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) { if (!header) {
DMERR("flashcache_writeback_load: Unable to allocate memory"); DMERR("flashcache_writeback_load: Unable to allocate memory");
return 1; return 1;
Expand Down

0 comments on commit c4bddf6

Please sign in to comment.