diff options
author | Milan Broz <mbroz@redhat.com> | 2009-01-06 03:05:01 +0000 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-01-06 03:05:01 +0000 |
commit | 2045e88edb4e0c9ce62d317f77dc59d27d9c530e (patch) | |
tree | 324eeea271b889263d0141fe0c82d4b0e43d0079 /drivers/md/dm-log.c | |
parent | 6f3af01cb0eda0ec50fe1e4cbdf028269dc396fe (diff) |
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>
Diffstat (limited to 'drivers/md/dm-log.c')
-rw-r--r-- | drivers/md/dm-log.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 691cb9c22b56..40ed70df6736 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -360,6 +360,17 @@ static int read_header(struct log_c *log) 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 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, } } - 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; } |