public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org,
	stable-review@kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	Anna Lemehova <EXT-Anna.Lemehova@nokia.com>,
	Adrian Hunter <adrian.hunter@nokia.com>,
	linux-mmc@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 26/52] mmc_block: add dev_t initialization check
Date: Thu, 14 Jan 2010 14:27:05 -0800	[thread overview]
Message-ID: <1263508051-7868-26-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <1263508051-7868-25-git-send-email-gregkh@suse.de>

From: Anna Lemehova <EXT-Anna.Lemehova@nokia.com>

commit 7d92df692994472cab6045bbd9d0e2c4afa4365f upstream.

When a card is removed before mmc_blk_probe() has called add_disk(), then
the minor field is uninitialized and has value 0.  This caused
mmc_blk_put() to always release devidx 0 even if 0 was still in use.  Then
the next mmc_blk_probe() used the first free idx of 0, which oopses in
sysfs, since it is used by another card.

Signed-off-by: Anna Lemehova <EXT-Anna.Lemehova@nokia.com>
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/mmc/card/block.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 85f0e8c..5988573 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -85,7 +85,12 @@ static void mmc_blk_put(struct mmc_blk_data *md)
 	mutex_lock(&open_lock);
 	md->usage--;
 	if (md->usage == 0) {
+		int devmaj = MAJOR(disk_devt(md->disk));
 		int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
+
+		if (!devmaj)
+			devidx = md->disk->first_minor >> MMC_SHIFT;
+
 		__clear_bit(devidx, dev_use);
 
 		put_disk(md->disk);
-- 
1.6.6


       reply	other threads:[~2010-01-14 22:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100114222551.GA7839@suse.de>
     [not found] ` <1263508051-7868-1-git-send-email-gregkh@suse.de>
     [not found]   ` <1263508051-7868-2-git-send-email-gregkh@suse.de>
     [not found]     ` <1263508051-7868-3-git-send-email-gregkh@suse.de>
     [not found]       ` <1263508051-7868-4-git-send-email-gregkh@suse.de>
     [not found]         ` <1263508051-7868-5-git-send-email-gregkh@suse.de>
     [not found]           ` <1263508051-7868-6-git-send-email-gregkh@suse.de>
     [not found]             ` <1263508051-7868-7-git-send-email-gregkh@suse.de>
     [not found]               ` <1263508051-7868-8-git-send-email-gregkh@suse.de>
     [not found]                 ` <1263508051-7868-9-git-send-email-gregkh@suse.de>
     [not found]                   ` <1263508051-7868-10-git-send-email-gregkh@suse.de>
     [not found]                     ` <1263508051-7868-11-git-send-email-gregkh@suse.de>
     [not found]                       ` <1263508051-7868-12-git-send-email-gregkh@suse.de>
     [not found]                         ` <1263508051-7868-13-git-send-email-gregkh@suse.de>
     [not found]                           ` <1263508051-7868-14-git-send-email-gregkh@suse.de>
     [not found]                             ` <1263508051-7868-15-git-send-email-gregkh@suse.de>
     [not found]                               ` <1263508051-7868-16-git-send-email-gregkh@suse.de>
     [not found]                                 ` <1263508051-7868-17-git-send-email-gregkh@suse.de>
     [not found]                                   ` <1263508051-7868-18-git-send-email-gregkh@suse.de>
     [not found]                                     ` <1263508051-7868-19-git-send-email-gregkh@suse.de>
     [not found]                                       ` <1263508051-7868-20-git-send-email-gregkh@suse.de>
     [not found]                                         ` <1263508051-7868-21-git-send-email-gregkh@suse.de>
     [not found]                                           ` <1263508051-7868-22-git-send-email-gregkh@suse.de>
     [not found]                                             ` <1263508051-7868-23-git-send-email-gregkh@suse.de>
     [not found]                                               ` <1263508051-7868-24-git-send-email-gregkh@suse.de>
     [not found]                                                 ` <1263508051-7868-25-git-send-email-gregkh@suse.de>
2010-01-14 22:27                                                   ` Greg Kroah-Hartman [this message]
2010-01-14 22:27                                                     ` [PATCH 27/52] mmc_block: fix probe error cleanup bug Greg Kroah-Hartman
2010-01-14 22:27                                                       ` [PATCH 28/52] mmc_block: fix queue cleanup Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1263508051-7868-26-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=EXT-Anna.Lemehova@nokia.com \
    --cc=adrian.hunter@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox