diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-09-16 16:59:22 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2016-10-02 22:48:14 +0200 |
commit | 9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9 (patch) | |
tree | 585c31efc8dc614a7bc705f73cfb8c69ae728913 /drivers/mtd/ubi/cdev.c | |
parent | 2d78aee426d821bbecbc80ee96ada5730ee68b6f (diff) | |
download | linux-stable-9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9.tar.gz linux-stable-9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9.tar.bz2 linux-stable-9a5f09ac0ab83e4a965a24edd6cf7cb0303c6dc9.zip |
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.c | 4 |
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, /* Validate the request */ err = -EINVAL; - if (req.lnum < 0 || req.lnum >= vol->reserved_pebs || + if (!ubi_leb_valid(vol, req.lnum) || req.bytes < 0 || req.bytes > vol->usable_leb_size) break; @@ -485,7 +485,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, break; } - if (lnum < 0 || lnum >= vol->reserved_pebs) { + if (!ubi_leb_valid(vol, lnum)) { err = -EINVAL; break; } |