scd: Avoid double-free on error condition in scd