From patchwork Sat Feb 25 16:57:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fubo Chen X-Patchwork-Id: 143061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 99F791007D1 for ; Sun, 26 Feb 2012 03:59:22 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1S1KwB-0007KS-IT; Sat, 25 Feb 2012 16:57:35 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1S1Kw4-0007Jw-SE for linux-mtd@lists.infradead.org; Sat, 25 Feb 2012 16:57:30 +0000 Received: by wgbdt13 with SMTP id dt13so1915240wgb.18 for ; Sat, 25 Feb 2012 08:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of fubo.chen@gmail.com designates 10.180.92.227 as permitted sender) client-ip=10.180.92.227; Authentication-Results: mr.google.com; spf=pass (google.com: domain of fubo.chen@gmail.com designates 10.180.92.227 as permitted sender) smtp.mail=fubo.chen@gmail.com; dkim=pass header.i=fubo.chen@gmail.com Received: from mr.google.com ([10.180.92.227]) by 10.180.92.227 with SMTP id cp3mr14650297wib.13.1330189045004 (num_hops = 1); Sat, 25 Feb 2012 08:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=aDny7THW0sVkOscqC06qdGBkuTx3Ro4LglhkTPG7JlM=; b=cwCXfsGf1hLC+0Bx0jZVYlA8KlINXVKLEXcsRq5Vo9Tudqp2hpHs9eSFVtWYUU8cJo u/gcPkgpAaIerGTNoyPKDmMmoIP55zWz2v5EQACE8V2MPUvrnGmHH+rh+Dwu9xzO4pi9 L+RWTRcXp8cP1CkBXTeD7OV6Tc8mSMBYz/o9A= Received: by 10.180.92.227 with SMTP id cp3mr11710070wib.13.1330189044894; Sat, 25 Feb 2012 08:57:24 -0800 (PST) Received: from fubochen (cust-134-112-110-94.dyn.as47377.net. [94.110.112.134]) by mx.google.com with ESMTPS id dr5sm26487403wib.0.2012.02.25.08.57.23 (version=SSLv3 cipher=OTHER); Sat, 25 Feb 2012 08:57:24 -0800 (PST) From: Fubo Chen To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: Fix memory leak triggered by removal Date: Sat, 25 Feb 2012 16:57:22 +0000 Message-ID: <4462354.EgehQQfXY4@asus> User-Agent: KMail/4.7.2 (Linux/3.2.7+; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (fubo.chen[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Make sure that blk_cleanup_queue() is called in del_mtd_blktrans_dev(). Signed-off-by: Fubo Chen Cc: David Woodhouse Cc: linux-mtd@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 */