diff options
Diffstat (limited to 'drivers/mtd/mtdchar.c')
| -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); |
