[MTD] Always initialise mutex in new mtd_blktrans_dev.
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 3 Dec 2007 12:46:12 +0000 (12:46 +0000)
committerDavid Woodhouse <dwmw2@infradead.org>
Mon, 3 Dec 2007 12:46:12 +0000 (12:46 +0000)
We were only initialising the mutex in the case where the new device was
automatically allocated the highest minor number. If the caller
specified a minor number, or if it filled in a free slot which was made
by a previous device deregistering, the mutex wouldn't get initialised
when we jumped out of the loop.

Reported by Monte Copeland <catboat@texas.net>

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/mtd_blkdevs.c

index 74d9d30edabdc49c04f42b435b53e851f159c3c5..839eed8430a2c77aaf1643937de83ae99501fe6b 100644 (file)
@@ -248,9 +248,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
                return -EBUSY;
        }
 
-       mutex_init(&new->lock);
        list_add_tail(&new->list, &tr->devs);
  added:
+       mutex_init(&new->lock);
        if (!tr->writesect)
                new->readonly = 1;