aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 94eb05b1afdf..f2f482bec573 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -106,16 +106,14 @@ static int mtdchar_open(struct inode *inode, struct file *file)
106 } 106 }
107 107
108 if (mtd->type == MTD_ABSENT) { 108 if (mtd->type == MTD_ABSENT) {
109 put_mtd_device(mtd);
110 ret = -ENODEV; 109 ret = -ENODEV;
111 goto out; 110 goto out1;
112 } 111 }
113 112
114 mtd_ino = iget_locked(mnt->mnt_sb, devnum); 113 mtd_ino = iget_locked(mnt->mnt_sb, devnum);
115 if (!mtd_ino) { 114 if (!mtd_ino) {
116 put_mtd_device(mtd);
117 ret = -ENOMEM; 115 ret = -ENOMEM;
118 goto out; 116 goto out1;
119 } 117 }
120 if (mtd_ino->i_state & I_NEW) { 118 if (mtd_ino->i_state & I_NEW) {
121 mtd_ino->i_private = mtd; 119 mtd_ino->i_private = mtd;
@@ -127,23 +125,25 @@ static int mtdchar_open(struct inode *inode, struct file *file)
127 125
128 /* You can't open it RW if it's not a writeable device */ 126 /* You can't open it RW if it's not a writeable device */
129 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) { 127 if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
130 iput(mtd_ino);
131 put_mtd_device(mtd);
132 ret = -EACCES; 128 ret = -EACCES;
133 goto out; 129 goto out2;
134 } 130 }
135 131
136 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); 132 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL);
137 if (!mfi) { 133 if (!mfi) {
138 iput(mtd_ino);
139 put_mtd_device(mtd);
140 ret = -ENOMEM; 134 ret = -ENOMEM;
141 goto out; 135 goto out2;
142 } 136 }
143 mfi->ino = mtd_ino; 137 mfi->ino = mtd_ino;
144 mfi->mtd = mtd; 138 mfi->mtd = mtd;
145 file->private_data = mfi; 139 file->private_data = mfi;
140 mutex_unlock(&mtd_mutex);
141 return 0;
146 142
143out2:
144 iput(mtd_ino);
145out1:
146 put_mtd_device(mtd);
147out: 147out:
148 mutex_unlock(&mtd_mutex); 148 mutex_unlock(&mtd_mutex);
149 simple_release_fs(&mnt, &count); 149 simple_release_fs(&mnt, &count);
@@ -376,7 +376,7 @@ static int otp_select_filemode(struct mtd_file_info *mfi, int mode)
376 * Make a fake call to mtd_read_fact_prot_reg() to check if OTP 376 * Make a fake call to mtd_read_fact_prot_reg() to check if OTP
377 * operations are supported. 377 * operations are supported.
378 */ 378 */
379 if (mtd_read_fact_prot_reg(mtd, -1, -1, &retlen, NULL) == -EOPNOTSUPP) 379 if (mtd_read_fact_prot_reg(mtd, -1, 0, &retlen, NULL) == -EOPNOTSUPP)
380 return -EOPNOTSUPP; 380 return -EOPNOTSUPP;
381 381
382 switch (mode) { 382 switch (mode) {