diff options
author | Richard Genoud <richard.genoud@gmail.com> | 2012-08-20 12:00:13 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-09-04 02:39:01 -0400 |
commit | d2f588f9340ed23dfb6cda08b8a1917ef3e8527c (patch) | |
tree | 162ea3e7fb652a79cf439f65b791a6287a9e4ce5 /drivers/mtd | |
parent | 256334c3191af9d9e520082db9beb75ff801d86c (diff) |
UBI: check max_beb_per1024 value in ubi_attach_mtd_dev
max_beb_per1024 shouldn't be negative, and a 0 value will be treated as
the default value. For the upper bound, 768/1024 should be enough.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/build.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 8a4eb7c3e0f4..3700bf77b0b8 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -49,6 +49,9 @@ | |||
49 | /* Maximum number of comma-separated items in the 'mtd=' parameter */ | 49 | /* Maximum number of comma-separated items in the 'mtd=' parameter */ |
50 | #define MTD_PARAM_MAX_COUNT 2 | 50 | #define MTD_PARAM_MAX_COUNT 2 |
51 | 51 | ||
52 | /* Maximum value for the number of bad PEBs per 1024 PEBs */ | ||
53 | #define MAX_MTD_UBI_BEB_LIMIT 768 | ||
54 | |||
52 | #ifdef CONFIG_MTD_UBI_MODULE | 55 | #ifdef CONFIG_MTD_UBI_MODULE |
53 | #define ubi_is_module() 1 | 56 | #define ubi_is_module() 1 |
54 | #else | 57 | #else |
@@ -852,6 +855,12 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, | |||
852 | struct ubi_device *ubi; | 855 | struct ubi_device *ubi; |
853 | int i, err, ref = 0; | 856 | int i, err, ref = 0; |
854 | 857 | ||
858 | if (max_beb_per1024 < 0 || max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT) | ||
859 | return -EINVAL; | ||
860 | |||
861 | if (!max_beb_per1024) | ||
862 | max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT; | ||
863 | |||
855 | /* | 864 | /* |
856 | * Check if we already have the same MTD device attached. | 865 | * Check if we already have the same MTD device attached. |
857 | * | 866 | * |