BUG at dcache.h:276! Causing oops when I rmmod a nand module having mulitple partitions (fix)

Brad Beveridge bbeveridge at bluewatersys.com
Wed Nov 24 14:24:53 EST 2004


Hi guys, we've managed to track down my mtd problem.

Setup:
- Using CONFIG_MTD_BLOCK
- Compiling your nand driver as a module
- Having multiple partitions defined

Problem:
insmodding the driver works, but when you rmmod the nand driver the 
kernel will oops.  The oops is caused by line 276 in dcache.h
The problem looks to be in mtd_blkdevs.c.  Everytime that 
add_mtd_blktrans_dev is called, a new gendisk is allocated, and its 
gd->queue member is set to
gd->queue = tr->blkcore_priv->rq;
The tr->blkcore_priv->rq appears to only get setup once in 
tr->blkcore_priv->rq.

Later, when del_mtd_blktrans_dev is called del_gendisk unregisters its 
queue.  So multiple gendisks point to the same queue & on removal they 
all try to get de-allocated.

Fix:
The very, very dodgy fix is to add
 ((struct gendisk *)old->blkcore_priv)->queue = NULL;
to del_mtd_blktrans_dev, just before del_gendisk is called.  This 
appears to let me rmmod my module without breakage.  Though I have no 
clue as to what the implications of doing this might be.

Can someone who knows the mtd_block layer better offer a proper fix?

Cheers
Brad





More information about the linux-mtd mailing list