summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/kapi.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-05-05 13:59:23 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-07-18 15:52:42 +0200
commit4ab60a0d7c92cab16f7e470f80ea039a0b174bce (patch)
tree79510835689011701745ce1cfe0f03319a3a1e61 /drivers/mtd/ubi/kapi.c
parentUBI: fix error path in create_vtbl() (diff)
downloadlinux-4ab60a0d7c92cab16f7e470f80ea039a0b174bce.tar.xz
linux-4ab60a0d7c92cab16f7e470f80ea039a0b174bce.zip
UBI: do not let to read too much
In case of static volumes it is prohibited to read more data then available. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r--drivers/mtd/ubi/kapi.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index d352c4575c3d..14c66b48798e 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -319,9 +319,14 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
offset + len > vol->usable_leb_size)
return -EINVAL;
- if (vol->vol_type == UBI_STATIC_VOLUME && lnum == vol->used_ebs - 1 &&
- offset + len > vol->last_eb_bytes)
- return -EINVAL;
+ if (vol->vol_type == UBI_STATIC_VOLUME) {
+ if (vol->used_ebs == 0)
+ /* Empty static UBI volume */
+ return 0;
+ if (lnum == vol->used_ebs - 1 &&
+ offset + len > vol->last_eb_bytes)
+ return -EINVAL;
+ }
if (vol->upd_marker)
return -EBADF;