aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/cdev.c
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-09-16 10:59:22 -0400
committerRichard Weinberger <richard@nod.at>2016-10-02 16:48:14 -0400
commit9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9 (patch)
tree585c31efc8dc614a7bc705f73cfb8c69ae728913 /drivers/mtd/ubi/cdev.c
parent2d78aee426d821bbecbc80ee96ada5730ee68b6f (diff)
UBI: add an helper to check lnum validity
ubi_leb_valid() is here to replace the lnum < 0 || lnum >= vol->reserved_pebs checks. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/ubi/cdev.c')
-rw-r--r--drivers/mtd/ubi/cdev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 3490dcd99ad1..45c329694a5e 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -454,7 +454,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
454 454
455 /* Validate the request */ 455 /* Validate the request */
456 err = -EINVAL; 456 err = -EINVAL;
457 if (req.lnum < 0 || req.lnum >= vol->reserved_pebs || 457 if (!ubi_leb_valid(vol, req.lnum) ||
458 req.bytes < 0 || req.bytes > vol->usable_leb_size) 458 req.bytes < 0 || req.bytes > vol->usable_leb_size)
459 break; 459 break;
460 460
@@ -485,7 +485,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
485 break; 485 break;
486 } 486 }
487 487
488 if (lnum < 0 || lnum >= vol->reserved_pebs) { 488 if (!ubi_leb_valid(vol, lnum)) {
489 err = -EINVAL; 489 err = -EINVAL;
490 break; 490 break;
491 } 491 }