diff options
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 11 |
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, | |||
319 | offset + len > vol->usable_leb_size) | 319 | offset + len > vol->usable_leb_size) |
320 | return -EINVAL; | 320 | return -EINVAL; |
321 | 321 | ||
322 | if (vol->vol_type == UBI_STATIC_VOLUME && lnum == vol->used_ebs - 1 && | 322 | if (vol->vol_type == UBI_STATIC_VOLUME) { |
323 | offset + len > vol->last_eb_bytes) | 323 | if (vol->used_ebs == 0) |
324 | return -EINVAL; | 324 | /* Empty static UBI volume */ |
325 | return 0; | ||
326 | if (lnum == vol->used_ebs - 1 && | ||
327 | offset + len > vol->last_eb_bytes) | ||
328 | return -EINVAL; | ||
329 | } | ||
325 | 330 | ||
326 | if (vol->upd_marker) | 331 | if (vol->upd_marker) |
327 | return -EBADF; | 332 | return -EBADF; |