Injections: fix undefined ref in error handler

Only try to remove a manually created injection target during error
cleanup if such a target was really created.