[PATCH] mtd: Fix memory leak triggered by removal
Fubo Chen
fubo.chen at gmail.com
Sat Feb 25 11:57:22 EST 2012
Make sure that blk_cleanup_queue() is called in del_mtd_blktrans_dev().
Signed-off-by: Fubo Chen <fubo.chen at gmail.com>
Cc: David Woodhouse <dwmw2 at infradead.org>
Cc: linux-mtd at lists.infradead.org
---
drivers/mtd/mtd_blkdevs.c | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 424ca5f..8b72f24 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -196,7 +196,7 @@ static void mtd_blktrans_request(struct request_queue *rq)
dev = rq->queuedata;
- if (!dev)
+ if (unlikely(blk_queue_dead(rq)))
while ((req = blk_fetch_request(rq)) != NULL)
__blk_end_request_all(req, -ENODEV);
else {
@@ -469,8 +469,6 @@ error1:
int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
{
- unsigned long flags;
-
if (mutex_trylock(&mtd_table_mutex)) {
mutex_unlock(&mtd_table_mutex);
BUG();
@@ -488,10 +486,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
kthread_stop(old->thread);
/* Kill current requests */
- spin_lock_irqsave(&old->queue_lock, flags);
- old->rq->queuedata = NULL;
- blk_start_queue(old->rq);
- spin_unlock_irqrestore(&old->queue_lock, flags);
+ blk_cleanup_queue(old->rq);
/* If the device is currently open, tell trans driver to close it,
then put mtd device, and don't touch it again */
--
1.7.7
More information about the linux-mtd
mailing list