diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index e14e5cb93c3cd..b28c486eae7a6 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -1943,7 +1943,11 @@ Status ProviderLibrary::Load() { } Provider* (*PGetProvider)(); - ORT_RETURN_IF_ERROR(Env::Default().GetSymbolFromLibrary(handle_, "GetProvider", (void**)&PGetProvider)); + auto status = Env::Default().GetSymbolFromLibrary(handle_, "GetProvider", (void**)&PGetProvider); + if (!status.IsOK()) { + Unload(); + return status; + } provider_ = PGetProvider(); }