diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-10-14 14:29:00 +0100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-10-14 14:29:00 +0100 |
commit | e3d18658d4f28e4783e1bb1c41e9134c9e5db0a9 (patch) | |
tree | d4fe529460e98522775bc0ecca557dcc76866999 /drivers/mtd/ubi/kapi.c | |
parent | a2e1b833d9e0231d67e722b7e2f4d79daf919baf (diff) | |
parent | cc5f4f28755b3b152297fd7bc3e03781dd8008e2 (diff) | |
download | lwn-e3d18658d4f28e4783e1bb1c41e9134c9e5db0a9.tar.gz lwn-e3d18658d4f28e4783e1bb1c41e9134c9e5db0a9.zip |
Merge branch 'master' of git://git.infradead.org/~dedekind/ubi-2.6
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 4a458e83e4e9..03c774f41549 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c @@ -99,16 +99,21 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode) { int err; struct ubi_volume_desc *desc; - struct ubi_device *ubi = ubi_devices[ubi_num]; + struct ubi_device *ubi; struct ubi_volume *vol; dbg_msg("open device %d volume %d, mode %d", ubi_num, vol_id, mode); err = -ENODEV; + if (ubi_num < 0) + return ERR_PTR(err); + + ubi = ubi_devices[ubi_num]; + if (!try_module_get(THIS_MODULE)) return ERR_PTR(err); - if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || !ubi) + if (ubi_num >= UBI_MAX_DEVICES || !ubi) goto out_put; err = -EINVAL; |