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

Fix flashcache contructor parameter check #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/flashcache_conf.c
Expand Up @@ -861,7 +861,8 @@ flashcache_get_dev(struct dm_target *ti, char *pth, struct dm_dev **dmd,
* arg[5]: cache block size (in sectors)
* arg[6]: cache size (in blocks)
* arg[7]: cache associativity
* arg[8]: md block size (in sectors)
* arg[8]: cache disk associativity
* arg[9]: md block size (in sectors)
*/
int
flashcache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
Expand Down Expand Up @@ -1003,7 +1004,7 @@ flashcache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
dmc->assoc = DEFAULT_CACHE_ASSOC;
dmc->assoc_shift = ffs(dmc->assoc) - 1;

if (argc >= 8) {
if (argc >= 9) {
if (sscanf(argv[8], "%u", &dmc->disk_assoc) != 1) {
ti->error = "flashcache: Invalid disk associativity";
r = -EINVAL;
Expand All @@ -1025,7 +1026,7 @@ flashcache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
dmc->disk_assoc_shift = ffs(dmc->disk_assoc) - 1;

if (dmc->cache_mode == FLASHCACHE_WRITE_BACK) {
if (argc >= 9) {
if (argc >= 10) {
if (sscanf(argv[9], "%u", &dmc->md_block_size) != 1) {
ti->error = "flashcache: Invalid metadata block size";
r = -EINVAL;
Expand Down