aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/dm-exception-store.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-09-08 16:27:31 +0900
committerPaul Mundt <lethal@linux-sh.org>2009-09-08 16:27:31 +0900
commite7a963ef20cabde53d0e609737764ddc65f4605a (patch)
treed2bf292f2dde9c6ee213d401abbbdc63fb3afa75 /drivers/md/dm-exception-store.c
parenta2494b9b5fb702becaf8d8e3138f7a1a0d3c537e (diff)
parent3ff323f89075624b6891e7c428edb8e8a35be13c (diff)
Merge branches 'sh/smp' and 'sh/stable-updates'
Diffstat (limited to 'drivers/md/dm-exception-store.c')
-rw-r--r--drivers/md/dm-exception-store.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 3710ff88fc1..556acff3952 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -171,6 +171,14 @@ static int set_chunk_size(struct dm_exception_store *store,
*/
chunk_size_ulong = round_up(chunk_size_ulong, PAGE_SIZE >> 9);
+ return dm_exception_store_set_chunk_size(store, chunk_size_ulong,
+ error);
+}
+
+int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
+ unsigned long chunk_size_ulong,
+ char **error)
+{
/* Check chunk_size is a power of 2 */
if (!is_power_of_2(chunk_size_ulong)) {
*error = "Chunk size is not a power of 2";
@@ -183,6 +191,11 @@ static int set_chunk_size(struct dm_exception_store *store,
return -EINVAL;
}
+ if (chunk_size_ulong > INT_MAX >> SECTOR_SHIFT) {
+ *error = "Chunk size is too high";
+ return -EINVAL;
+ }
+
store->chunk_size = chunk_size_ulong;
store->chunk_mask = chunk_size_ulong - 1;
store->chunk_shift = ffs(chunk_size_ulong) - 1;