dm log: move region_size validation
Move log size validation from mirror target to log constructor.
Removed PAGE_SIZE restriction we no longer think necessary.
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 691cb9c..40ed70d 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -360,6 +360,17 @@
return 0;
}
+static int _check_region_size(struct dm_target *ti, uint32_t region_size)
+{
+ if (region_size < 2 || region_size > ti->len)
+ return 0;
+
+ if (!is_power_of_2(region_size))
+ return 0;
+
+ return 1;
+}
+
/*----------------------------------------------------------------
* core log constructor/destructor
*
@@ -395,8 +406,9 @@
}
}
- if (sscanf(argv[0], "%u", ®ion_size) != 1) {
- DMWARN("invalid region size string");
+ if (sscanf(argv[0], "%u", ®ion_size) != 1 ||
+ !_check_region_size(ti, region_size)) {
+ DMWARN("invalid region size %s", argv[0]);
return -EINVAL;
}