when register fail, free some alloc's memory