aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-log.c')
-rw-r--r--drivers/md/dm-log.c16
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)
360 return 0; 360 return 0;
361} 361}
362 362
363static int _check_region_size(struct dm_target *ti, uint32_t region_size)
364{
365 if (region_size < 2 || region_size > ti->len)
366 return 0;
367
368 if (!is_power_of_2(region_size))
369 return 0;
370
371 return 1;
372}
373
363/*---------------------------------------------------------------- 374/*----------------------------------------------------------------
364 * core log constructor/destructor 375 * core log constructor/destructor
365 * 376 *
@@ -395,8 +406,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
395 } 406 }
396 } 407 }
397 408
398 if (sscanf(argv[0], "%u", &region_size) != 1) { 409 if (sscanf(argv[0], "%u", &region_size) != 1 ||
399 DMWARN("invalid region size string"); 410 !_check_region_size(ti, region_size)) {
411 DMWARN("invalid region size %s", argv[0]);
400 return -EINVAL; 412 return -EINVAL;
401 } 413 }
402 414