diff options
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index d352c4575c3d..4a458e83e4e9 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c | |||
@@ -37,14 +37,9 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di) | |||
37 | { | 37 | { |
38 | const struct ubi_device *ubi; | 38 | const struct ubi_device *ubi; |
39 | 39 | ||
40 | if (!try_module_get(THIS_MODULE)) | ||
41 | return -ENODEV; | ||
42 | |||
43 | if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || | 40 | if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || |
44 | !ubi_devices[ubi_num]) { | 41 | !ubi_devices[ubi_num]) |
45 | module_put(THIS_MODULE); | ||
46 | return -ENODEV; | 42 | return -ENODEV; |
47 | } | ||
48 | 43 | ||
49 | ubi = ubi_devices[ubi_num]; | 44 | ubi = ubi_devices[ubi_num]; |
50 | di->ubi_num = ubi->ubi_num; | 45 | di->ubi_num = ubi->ubi_num; |
@@ -52,7 +47,6 @@ int ubi_get_device_info(int ubi_num, struct ubi_device_info *di) | |||
52 | di->min_io_size = ubi->min_io_size; | 47 | di->min_io_size = ubi->min_io_size; |
53 | di->ro_mode = ubi->ro_mode; | 48 | di->ro_mode = ubi->ro_mode; |
54 | di->cdev = MKDEV(ubi->major, 0); | 49 | di->cdev = MKDEV(ubi->major, 0); |
55 | module_put(THIS_MODULE); | ||
56 | return 0; | 50 | return 0; |
57 | } | 51 | } |
58 | EXPORT_SYMBOL_GPL(ubi_get_device_info); | 52 | EXPORT_SYMBOL_GPL(ubi_get_device_info); |
@@ -319,9 +313,14 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | |||
319 | offset + len > vol->usable_leb_size) | 313 | offset + len > vol->usable_leb_size) |
320 | return -EINVAL; | 314 | return -EINVAL; |
321 | 315 | ||
322 | if (vol->vol_type == UBI_STATIC_VOLUME && lnum == vol->used_ebs - 1 && | 316 | if (vol->vol_type == UBI_STATIC_VOLUME) { |
323 | offset + len > vol->last_eb_bytes) | 317 | if (vol->used_ebs == 0) |
324 | return -EINVAL; | 318 | /* Empty static UBI volume */ |
319 | return 0; | ||
320 | if (lnum == vol->used_ebs - 1 && | ||
321 | offset + len > vol->last_eb_bytes) | ||
322 | return -EINVAL; | ||
323 | } | ||
325 | 324 | ||
326 | if (vol->upd_marker) | 325 | if (vol->upd_marker) |
327 | return -EBADF; | 326 | return -EBADF; |