Fixes memory leak with device sockets