UBI: fix use-after-free on error path