aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/kapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/kapi.c')
-rw-r--r--drivers/mtd/ubi/kapi.c9
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)
99{ 99{
100 int err; 100 int err;
101 struct ubi_volume_desc *desc; 101 struct ubi_volume_desc *desc;
102 struct ubi_device *ubi = ubi_devices[ubi_num]; 102 struct ubi_device *ubi;
103 struct ubi_volume *vol; 103 struct ubi_volume *vol;
104 104
105 dbg_msg("open device %d volume %d, mode %d", ubi_num, vol_id, mode); 105 dbg_msg("open device %d volume %d, mode %d", ubi_num, vol_id, mode);
106 106
107 err = -ENODEV; 107 err = -ENODEV;
108 if (ubi_num < 0)
109 return ERR_PTR(err);
110
111 ubi = ubi_devices[ubi_num];
112
108 if (!try_module_get(THIS_MODULE)) 113 if (!try_module_get(THIS_MODULE))
109 return ERR_PTR(err); 114 return ERR_PTR(err);
110 115
111 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES || !ubi) 116 if (ubi_num >= UBI_MAX_DEVICES || !ubi)
112 goto out_put; 117 goto out_put;
113 118
114 err = -EINVAL; 119 err = -EINVAL;