diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index c33e25b..dee90b7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -668,13 +668,12 @@ static int io_init(struct ubi_device *ubi)
                ubi->bad_allowed = 1;
                if (CONFIG_MTD_UBI_BEB_LIMIT > 0) {
                        int percent = CONFIG_MTD_UBI_BEB_LIMIT;
-                       int beb_limit;
+                       int limit = mult_frac(ubi->peb_count, percent, 100);
 
-                       beb_limit = mult_frac(ubi->peb_count, percent, 100);
-                       /* round it up */
-                       if (mult_frac(beb_limit, 100, percent) < ubi->peb_count)
-                               beb_limit++;
-                       ubi->bad_peb_limit = beb_limit;
+                       /* Round it up */
+                       if (mult_frac(limit, 100, percent) < ubi->peb_count)
+                               limit += 1;
+                       ubi->bad_peb_limit = limit;
                }
        }

