diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-09 01:36:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-04-09 01:38:55 -0400 |
commit | c65390f4dd49755863f6d772ec538ee4757c08d7 (patch) | |
tree | 865105e059ac8d78da90d371542e888995e0581e /drivers/mtd | |
parent | 0034102808e0dbbf3a2394b82b1bb40b5778de9e (diff) |
fix breakage in mtdchar_open(), sanitize failure exits
simple_release_fs() should be only done on failure there.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdchar.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 94eb05b1afdf..58fc65f5c817 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 | ||
143 | out2: | ||
144 | iput(mtd_ino); | ||
145 | out1: | ||
146 | put_mtd_device(mtd); | ||
147 | out: | 147 | out: |
148 | mutex_unlock(&mtd_mutex); | 148 | mutex_unlock(&mtd_mutex); |
149 | simple_release_fs(&mnt, &count); | 149 | simple_release_fs(&mnt, &count); |