nameservice: fix a resource leak