[MTD] Use after free, found by the Coverity tool