aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/mtd_blkdevs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 2b0c52870999..df7c6c70757a 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -197,6 +197,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
197 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ 197 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
198 198
199 mutex_lock(&dev->lock); 199 mutex_lock(&dev->lock);
200 mutex_lock(&mtd_table_mutex);
200 201
201 if (dev->open) 202 if (dev->open)
202 goto unlock; 203 goto unlock;
@@ -220,6 +221,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
220 221
221unlock: 222unlock:
222 dev->open++; 223 dev->open++;
224 mutex_unlock(&mtd_table_mutex);
223 mutex_unlock(&dev->lock); 225 mutex_unlock(&dev->lock);
224 blktrans_dev_put(dev); 226 blktrans_dev_put(dev);
225 return ret; 227 return ret;
@@ -230,6 +232,7 @@ error_release:
230error_put: 232error_put:
231 module_put(dev->tr->owner); 233 module_put(dev->tr->owner);
232 kref_put(&dev->ref, blktrans_dev_release); 234 kref_put(&dev->ref, blktrans_dev_release);
235 mutex_unlock(&mtd_table_mutex);
233 mutex_unlock(&dev->lock); 236 mutex_unlock(&dev->lock);
234 blktrans_dev_put(dev); 237 blktrans_dev_put(dev);
235 return ret; 238 return ret;
@@ -243,6 +246,7 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode)
243 return; 246 return;
244 247
245 mutex_lock(&dev->lock); 248 mutex_lock(&dev->lock);
249 mutex_lock(&mtd_table_mutex);
246 250
247 if (--dev->open) 251 if (--dev->open)
248 goto unlock; 252 goto unlock;
@@ -256,6 +260,7 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode)
256 __put_mtd_device(dev->mtd); 260 __put_mtd_device(dev->mtd);
257 } 261 }
258unlock: 262unlock:
263 mutex_unlock(&mtd_table_mutex);
259 mutex_unlock(&dev->lock); 264 mutex_unlock(&dev->lock);
260 blktrans_dev_put(dev); 265 blktrans_dev_put(dev);
261} 266}