diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 9dd23d6acbb6c9b452a74a77514bed8379874946..e32c49cb4005964e4c1c13ce4982e495a6569b50 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -380,9 +380,11 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 
 	add_disk(gd);
 
-	if (new->disk_attributes)
-		sysfs_create_group(&disk_to_dev(gd)->kobj,
+	if (new->disk_attributes) {
+		ret = sysfs_create_group(&disk_to_dev(gd)->kobj,
 					new->disk_attributes);
+		WARN_ON(ret);
+	}
 	return 0;
 error4:
 	module_put(tr->owner);
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 7ce30a239ada05cf339106c58a78a569bd799cf4..e6edbec609fd61e68a5a53967aea4671e8ac2888 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -354,7 +354,6 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
 {
-	struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
 	del_mtd_blktrans_dev(dev);
 }
 
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index 9307a88e522939e7d4006b527df64904807b64e9..7a616a926ee9e72624eba4b6277a57f5d9ef8bae 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -654,7 +654,9 @@ int r852_register_nand_device(struct r852_device *dev)
 	if (sm_register_device(dev->mtd))
 		goto error2;
 
-	device_create_file(&dev->mtd->dev, &dev_attr_media_type);
+	if (device_create_file(&dev->mtd->dev, &dev_attr_media_type))
+		message("can't create media type sysfs attribute");
+
 	dev->card_registred = 1;
 	return 0;
 error2:
@@ -838,7 +840,7 @@ int  r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 
 	pci_set_master(pci_dev);
 
-	error = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK);
+	error = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
 	if (error)
 		goto error2;
 
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
index a59ebb48cae1e72dd6d7c362d07c27093adc6adb..9fb56c76ae899560bc30c94e2fb683d7f879e01b 100644
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -228,7 +228,7 @@ static int sm_read_sector(struct sm_ftl *ftl,
 	struct mtd_info *mtd = ftl->trans->mtd;
 	struct mtd_oob_ops ops;
 	struct sm_oob tmp_oob;
-	int ret;
+	int ret = -EIO;
 	int try = 0;
 
 	/* FTL can contain -1 entries that are by default filled with bits */
@@ -753,6 +753,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
 	uint16_t block;
 	int lba;
 	int i = 0;
+	int len;
 
 	dbg("initializing zone %d", zone_num);
 
@@ -856,7 +857,9 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
 	i %= (kfifo_len(&zone->free_sectors) / 2);
 
 	while (i--) {
-		kfifo_out(&zone->free_sectors, (unsigned char *)&block, 2);
+		len = kfifo_out(&zone->free_sectors,
+					(unsigned char *)&block, 2);
+		WARN_ON(len != 2);
 		kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
 	}
 	return 0;
@@ -947,17 +950,17 @@ int sm_cache_flush(struct sm_ftl *ftl)
 
 	if (ftl->unstable)
 		return -EIO;
-	/* No spare blocks */
-	/* We could still continue by erasing the current block,
+
+	/* If there are no spare blocks, */
+	/* we could still continue by erasing/writing the current block,
 		but for such worn out media it doesn't worth the trouble,
 			and the dangers */
-
-	if (!kfifo_len(&zone->free_sectors)) {
+	if (kfifo_out(&zone->free_sectors,
+				(unsigned char *)&write_sector, 2) != 2) {
 		dbg("no free sectors for write!");
 		return -EIO;
 	}
 
-	kfifo_out(&zone->free_sectors, (unsigned char *)&write_sector, 2);
 
 	if (sm_write_block(ftl, ftl->cache_data, zone_num, write_sector,
 		ftl->cache_block, ftl->cache_data_invalid_bitmap))