[PATCH 1/4] mtd: block2mtd: char mtd major check

Fabian Frederick fabf at skynet.be
Thu Jan 23 14:49:47 EST 2014


Deny use of a char mtd device to map as a block device.

Signed-off-by: Fabian Frederick <fabf at skynet.be>
---
 drivers/mtd/devices/block2mtd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index d9fd87a..0efee5b 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -244,7 +244,8 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
 	}
 	dev->blkdev = bdev;
 
-	if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
+	if ((MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) ||
+	    (MAJOR(bdev->bd_dev) == MTD_CHAR_MAJOR)) {
 		pr_err("attempting to use an MTD device as a block device\n");
 		goto devinit_err;
 	}
-- 
1.8.1.4



More information about the linux-mtd mailing list