fix kmalloc leak and dead-lock mutex