Merge branch 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind...
[firefly-linux-kernel-4.4.55.git] / drivers / mtd / mtdblock_ro.c
index f79dbb49b1a2601ae596283d75ca83564121d0d5..d0d3f79f9d03e7a94a38f8c6d8f2f96530876c99 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: mtdblock_ro.c,v 1.19 2004/11/16 18:28:59 dwmw2 Exp $
- *
  * (C) 2003 David Woodhouse <dwmw2@infradead.org>
  *
  * Simple read-only (writable only for RAM) mtdblock driver
@@ -45,13 +43,13 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
        dev->tr = tr;
        dev->readonly = 1;
 
-       add_mtd_blktrans_dev(dev);
+       if (add_mtd_blktrans_dev(dev))
+               kfree(dev);
 }
 
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
 {
        del_mtd_blktrans_dev(dev);
-       kfree(dev);
 }
 
 static struct mtd_blktrans_ops mtdblock_tr = {