[PATCH] mtd: Fix memory leak triggered by removal

Artem Bityutskiy dedekind1 at gmail.com
Fri Mar 9 04:49:07 EST 2012


On Sat, 2012-02-25 at 16:57 +0000, Fubo Chen wrote:
>  	dev = rq->queuedata;
>  
> -	if (!dev)
> +	if (unlikely(blk_queue_dead(rq)))
>  		while ((req = blk_fetch_request(rq)) != NULL)
>  			__blk_end_request_all(req, -ENODEV);

I think this should be a separate patch with own commit message and
explanation. I guess you can kill 'dev' as well then?

>  	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);

Please, provide better explanation in the commit message about which
problem you solve, why you do this, and how you tested this.
blktrans_dev_release() also calls blk_cleanup_queue() - why we need to
do it 2 times?

-- 
Best Regards,
Artem Bityutskiy




More information about the linux-mtd mailing list