set_ktest: handle error cases
get_patch: handle error cases
apply_patch: handle error cases