kmscube: fix resource leaks & freeing