Skip to contentSkip to conversation

dynamic mtd_blktrans_dev not fully init'd under UBI?

DISCUSSION [email protected] 2 participants 3 messages Nov 30, 2007 – Dec 1, 2007 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi all,

I have a UBI system, and I notice this causes a kernel panic. Make a volume that does not previously exist, eg 50:

ubimkvol -d0 -n50 -N vol50 -s 640000
cat /dev/mtdblock/vol50 >/dev/null

I get a panic in mtdblockd as it handles the block requests generated by cat.

In older versions, the struct semaphore of mtd_blktrans_dev is not initialized, so the kernel panics in __down.

In the newest git, I see a mutex named "lock" instead, but I don't think it's initialized either. See the function mtdblock_add_mtd() in drivers/mtd/mtdblock.c. The struct mtd_blktrans_dev is just kzalloc'd leaving the mutex lock all zeroes.

Can anybody recreate this?

Monte Copeland
IBM Austin

#1 lore raw
Quoted 5 lines · On Fri, 2007-11-30 at 14:58 -0600, [email protected] wrote:

In the newest git, I see a mutex named "lock" instead, but I don't think it's initialized either. See the function mtdblock_add_mtd() in drivers/mtd/mtdblock.c. The struct mtd_blktrans_dev is just kzalloc'd leaving the mutex lock all zeroes.

drivers/mtd/mtd_blkdevs.c +1 -1
index 74d9d30..839eed8 100644
@@ -248,9 +248,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 		return -EBUSY;
 	}
 
-	mutex_init(&new->lock);
 	list_add_tail(&new->list, &tr->devs);
  added:
+	mutex_init(&new->lock);
 	if (!tr->writesect)
 		new->readonly = 1;
 
Signature · 1 line
dwmw2
#2 lore raw

Thanks David.

Quoting David Woodhouse <[email protected]>:

Quoted 28 lines · On Fri, 2007-11-30 at 14:58 -0600, [email protected] wrote:
Quoted 5 lines

In the newest git, I see a mutex named "lock" instead, but I don't think it's initialized either. See the function mtdblock_add_mtd() in drivers/mtd/mtdblock.c. The struct mtd_blktrans_dev is just kzalloc'd leaving the mutex lock all zeroes.

drivers/mtd/mtd_blkdevs.c +1 -1
index 74d9d30..839eed8 100644
@@ -248,9 +248,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 		return -EBUSY;
 	}
 
-	mutex_init(&new->lock);
 	list_add_tail(&new->list, &tr->devs);
  added:
+	mutex_init(&new->lock);
 	if (!tr->writesect)
 		new->readonly = 1;
 
Signature · 2 lines
-- 
dwmw2