mem_ap: fix a potential memory leak in mem_ap_target_create()