From 94f52f0d7c2080455985e1651af765e3c8499423 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:28:00 +0200 Subject: [PATCH] client.GetQuoteProvider: return error if none supported Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- client/client_linux.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/client/client_linux.go b/client/client_linux.go index 72ed35d..b7b81bf 100644 --- a/client/client_linux.go +++ b/client/client_linux.go @@ -235,18 +235,28 @@ func (*LinuxConfigFsQuoteProvider) Product() *spb.SevProduct { // GetQuoteProvider returns a supported SEV-SNP QuoteProvider. func GetQuoteProvider() (QuoteProvider, error) { - preferred := &LinuxConfigFsQuoteProvider{} - if !preferred.IsSupported() { - return &LinuxIoctlQuoteProvider{}, nil + var provider QuoteProvider + provider = &LinuxConfigFsQuoteProvider{} + if provider.IsSupported() { + return provider, nil } - return preferred, nil + provider = &LinuxIoctlQuoteProvider{} + if provider.IsSupported() { + return provider, nil + } + return nil, fmt.Errorf("no supported SEV-SNP QuoteProvider found") } // GetLeveledQuoteProvider returns a supported SEV-SNP LeveledQuoteProvider. func GetLeveledQuoteProvider() (LeveledQuoteProvider, error) { - preferred := &LinuxConfigFsQuoteProvider{} - if !preferred.IsSupported() { - return &LinuxIoctlQuoteProvider{}, nil + var provider LeveledQuoteProvider + provider = &LinuxConfigFsQuoteProvider{} + if provider.IsSupported() { + return provider, nil + } + provider = &LinuxIoctlQuoteProvider{} + if provider.IsSupported() { + return provider, nil } - return preferred, nil + return nil, fmt.Errorf("no supported SEV-SNP LeveledQuoteProvider found") }