From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org,
donari75@gmail.com, bzolnier@gmail.com,
linux-ide@vger.kernel.org, alan@lxorguk.ukuu.org.uk
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 1/3] mg_disk: fix locking
Date: Tue, 28 Apr 2009 12:52:17 +0900 [thread overview]
Message-ID: <1240890740-3462-2-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1240890740-3462-1-git-send-email-tj@kernel.org>
IRQ and timeout handlers call functions which expect locked queue lock
without locking it. Fix it.
While at it, convert 0s used as null pointer constant to NULLs.
[ Impact: fix locking, cleanup ]
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: unsik Kim <donari75@gmail.com>
---
drivers/block/mg_disk.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index fb39d9a..d3e72ad 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -160,11 +160,16 @@ static irqreturn_t mg_irq(int irq, void *dev_id)
struct mg_host *host = dev_id;
void (*handler)(struct mg_host *) = host->mg_do_intr;
- host->mg_do_intr = 0;
+ spin_lock(&host->lock);
+
+ host->mg_do_intr = NULL;
del_timer(&host->timer);
if (!handler)
handler = mg_unexpected_intr;
handler(host);
+
+ spin_unlock(&host->lock);
+
return IRQ_HANDLED;
}
@@ -319,7 +324,7 @@ static void mg_read(struct request *req)
remains = req->nr_sectors;
- if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_RD, 0) !=
+ if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_RD, NULL) !=
MG_ERR_NONE)
mg_bad_rw_intr(host);
@@ -363,7 +368,7 @@ static void mg_write(struct request *req)
remains = req->nr_sectors;
- if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_WR, 0) !=
+ if (mg_out(host, req->sector, req->nr_sectors, MG_CMD_WR, NULL) !=
MG_ERR_NONE) {
mg_bad_rw_intr(host);
return;
@@ -521,9 +526,11 @@ void mg_times_out(unsigned long data)
char *name;
struct request *req;
+ spin_lock_irq(&host->lock);
+
req = elv_next_request(host->breq);
if (!req)
- return;
+ goto out_unlock;
host->mg_do_intr = NULL;
@@ -534,6 +541,8 @@ void mg_times_out(unsigned long data)
mg_bad_rw_intr(host);
mg_request(host->breq);
+out_unlock:
+ spin_unlock_irq(&host->lock);
}
static void mg_request_poll(struct request_queue *q)
--
1.6.0.2
next prev parent reply other threads:[~2009-04-28 3:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-28 3:52 [GIT PATCH linux-2.6-block#for-linus] block: fix hd and mg_disk Tejun Heo
2009-04-28 3:52 ` Tejun Heo [this message]
2009-04-28 3:52 ` [PATCH 2/3] mg_disk: fix CONFIG_LBD=y warning Tejun Heo
2009-04-28 15:19 ` Mark Lord
2009-04-28 15:28 ` Bartlomiej Zolnierkiewicz
2009-04-28 18:09 ` Jeff Garzik
2009-04-28 18:28 ` Bartlomiej Zolnierkiewicz
2009-04-28 3:52 ` [PATCH 3/3] hd: fix locking Tejun Heo
2009-04-28 5:36 ` [GIT PATCH linux-2.6-block#for-linus] block: fix hd and mg_disk Jens Axboe
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=1240890740-3462-2-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=axboe@kernel.dk \
--cc=bzolnier@gmail.com \
--cc=donari75@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).