[MTD] fix use after free in register_mtd_blktrans
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sat, 28 Mar 2009 17:44:24 +0000 (18:44 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 3 Apr 2009 09:36:23 +0000 (10:36 +0100)
Reported-by: Dan Carpenter <error27@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtd_blkdevs.c

index 1409f01406f6e7ebc356cf906ab4880f7719b1c1..4109e0bb94f58fcb986c8b0bd48a3f45ec368c16 100644 (file)
@@ -382,11 +382,12 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
        tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr,
                        "%sd", tr->name);
        if (IS_ERR(tr->blkcore_priv->thread)) {
+               int ret = PTR_ERR(tr->blkcore_priv->thread);
                blk_cleanup_queue(tr->blkcore_priv->rq);
                unregister_blkdev(tr->major, tr->name);
                kfree(tr->blkcore_priv);
                mutex_unlock(&mtd_table_mutex);
-               return PTR_ERR(tr->blkcore_priv->thread);
+               return ret;
        }
 
        INIT_LIST_HEAD(&tr->devs);