Skip to contentSkip to conversation

mmc_test: initialize mmc_test_lock statically

PATCH In review Akinobu Mita 2 participants 2 messages Sep 13, 2008 – Sep 20, 2008 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc_test: initialize mmc_test_lock statically

The mutex mmc_test_lock is initialized at every time mmc_test device is probed. Probing another mmc_test device may break the mutex, if the probe function is called while the mutex is locked.

This patch fixes it by statically initializing mmc_test_lock.

---
 drivers/mmc/card/mmc_test.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/card/mmc_test.c +1 -3
Index: 2.6-git/drivers/mmc/card/mmc_test.c
===================================================================
@@ -1040,7 +1040,7 @@ static const struct mmc_test_case mmc_te
 
 };
 
-static struct mutex mmc_test_lock;
+static DEFINE_MUTEX(mmc_test_lock);
 
 static void mmc_test_run(struct mmc_test_card *test, int testcase)
 {
@@ -1171,8 +1171,6 @@ static int mmc_test_probe(struct mmc_car
 	if ((card->type != MMC_TYPE_MMC) && (card->type != MMC_TYPE_SD))
 		return -ENODEV;
 
-	mutex_init(&mmc_test_lock);
-
 	ret = device_create_file(&card->dev, &dev_attr_test);
 	if (ret)
 		return ret;
#1 lore raw
Quoted 9 lines · On Sat, 13 Sep 2008 19:03:32 +0900 Akinobu Mita <[email protected]> wrote:

The mutex mmc_test_lock is initialized at every time mmc_test device is probed. Probing another mmc_test device may break the mutex, if the probe function is called while the mutex is locked.

This patch fixes it by statically initializing mmc_test_lock.

---

Also applied.

Signature · 9 lines
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.