UBI: fix a horrible memory deallocation bug