diff --git a/lib/libzfs/libzfs_crypto.c b/lib/libzfs/libzfs_crypto.c index 1a2ee638aef3..fe3a0f28360e 100644 --- a/lib/libzfs/libzfs_crypto.c +++ b/lib/libzfs/libzfs_crypto.c @@ -532,6 +532,8 @@ get_key_material(libzfs_handle_t *hdl, boolean_t do_verify, boolean_t newkey, break; case ZFS_KEYLOCATION_URI: + ret = ENOTSUP; + for (handler = uri_handlers; handler->zuh_scheme != NULL; handler++) { if (strcmp(handler->zuh_scheme, uri_scheme) != 0) @@ -544,9 +546,11 @@ get_key_material(libzfs_handle_t *hdl, boolean_t do_verify, boolean_t newkey, break; } - ret = ENOTSUP; - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "URI scheme is not supported")); + if (ret == ENOTSUP) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "URI scheme is not supported")); + goto error; + } break; default: