hsa: fix memory management bugs